1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir //------------------------------------------------------------------ 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir // INCLUDE --------------------------------------------------------------- 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include "scitems.hxx" 38*cdf0e10cSrcweir #include <vcl/virdev.hxx> 39*cdf0e10cSrcweir #include <vcl/waitobj.hxx> 40*cdf0e10cSrcweir #include <editeng/boxitem.hxx> 41*cdf0e10cSrcweir #include <sfx2/app.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #include "undoblk.hxx" 44*cdf0e10cSrcweir #include "undoutil.hxx" 45*cdf0e10cSrcweir #include "document.hxx" 46*cdf0e10cSrcweir #include "patattr.hxx" 47*cdf0e10cSrcweir #include "docsh.hxx" 48*cdf0e10cSrcweir #include "tabvwsh.hxx" 49*cdf0e10cSrcweir #include "rangenam.hxx" 50*cdf0e10cSrcweir #include "rangeutl.hxx" 51*cdf0e10cSrcweir #include "dbcolect.hxx" 52*cdf0e10cSrcweir #include "stlpool.hxx" 53*cdf0e10cSrcweir #include "stlsheet.hxx" 54*cdf0e10cSrcweir #include "globstr.hrc" 55*cdf0e10cSrcweir #include "global.hxx" 56*cdf0e10cSrcweir #include "target.hxx" 57*cdf0e10cSrcweir #include "docpool.hxx" 58*cdf0e10cSrcweir #include "docfunc.hxx" 59*cdf0e10cSrcweir #include "attrib.hxx" 60*cdf0e10cSrcweir #include "chgtrack.hxx" 61*cdf0e10cSrcweir #include "transobj.hxx" 62*cdf0e10cSrcweir #include "refundo.hxx" 63*cdf0e10cSrcweir #include "undoolk.hxx" 64*cdf0e10cSrcweir #include "clipparam.hxx" 65*cdf0e10cSrcweir #include "sc.hrc" 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir // STATIC DATA ----------------------------------------------------------- 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir TYPEINIT1(ScUndoInsertCells, SfxUndoAction); 71*cdf0e10cSrcweir TYPEINIT1(ScUndoDeleteCells, SfxUndoAction); 72*cdf0e10cSrcweir TYPEINIT1(ScUndoDeleteMulti, SfxUndoAction); 73*cdf0e10cSrcweir TYPEINIT1(ScUndoCut, ScBlockUndo); 74*cdf0e10cSrcweir TYPEINIT1(ScUndoPaste, SfxUndoAction); 75*cdf0e10cSrcweir TYPEINIT1(ScUndoDragDrop, SfxUndoAction); 76*cdf0e10cSrcweir TYPEINIT1(ScUndoListNames, SfxUndoAction); 77*cdf0e10cSrcweir TYPEINIT1(ScUndoUseScenario, SfxUndoAction); 78*cdf0e10cSrcweir TYPEINIT1(ScUndoSelectionStyle, SfxUndoAction); 79*cdf0e10cSrcweir TYPEINIT1(ScUndoEnterMatrix, ScBlockUndo); 80*cdf0e10cSrcweir TYPEINIT1(ScUndoIndent, ScBlockUndo); 81*cdf0e10cSrcweir TYPEINIT1(ScUndoTransliterate, ScBlockUndo); 82*cdf0e10cSrcweir TYPEINIT1(ScUndoClearItems, ScBlockUndo); 83*cdf0e10cSrcweir TYPEINIT1(ScUndoRemoveBreaks, SfxUndoAction); 84*cdf0e10cSrcweir TYPEINIT1(ScUndoRemoveMerge, ScBlockUndo); 85*cdf0e10cSrcweir TYPEINIT1(ScUndoBorder, ScBlockUndo); 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir // To Do: 90*cdf0e10cSrcweir /*A*/ // SetOptimalHeight auf Dokument, wenn keine View 91*cdf0e10cSrcweir /*B*/ // gelinkte Tabellen 92*cdf0e10cSrcweir /*C*/ // ScArea 93*cdf0e10cSrcweir //? // spaeter mal pruefen 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir // ----------------------------------------------------------------------- 97*cdf0e10cSrcweir // 98*cdf0e10cSrcweir // Zellen einfuegen 99*cdf0e10cSrcweir // Zeilen einfuegen 100*cdf0e10cSrcweir // einzeln oder Block 101*cdf0e10cSrcweir // 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir ScUndoInsertCells::ScUndoInsertCells( ScDocShell* pNewDocShell, 104*cdf0e10cSrcweir const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios, 105*cdf0e10cSrcweir InsCellCmd eNewCmd, ScDocument* pUndoDocument, ScRefUndoData* pRefData, 106*cdf0e10cSrcweir sal_Bool bNewPartOfPaste ) : 107*cdf0e10cSrcweir ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ), 108*cdf0e10cSrcweir aEffRange( rRange ), 109*cdf0e10cSrcweir nCount( nNewCount ), 110*cdf0e10cSrcweir pTabs( pNewTabs ), 111*cdf0e10cSrcweir pScenarios( pNewScenarios ), 112*cdf0e10cSrcweir eCmd( eNewCmd ), 113*cdf0e10cSrcweir bPartOfPaste( bNewPartOfPaste ), 114*cdf0e10cSrcweir pPasteUndo( NULL ) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir if (eCmd == INS_INSROWS) // ganze Zeilen? 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir aEffRange.aStart.SetCol(0); 119*cdf0e10cSrcweir aEffRange.aEnd.SetCol(MAXCOL); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir if (eCmd == INS_INSCOLS) // ganze Spalten? 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir aEffRange.aStart.SetRow(0); 125*cdf0e10cSrcweir aEffRange.aEnd.SetRow(MAXROW); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir SetChangeTrack(); 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir __EXPORT ScUndoInsertCells::~ScUndoInsertCells() 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir delete pPasteUndo; 134*cdf0e10cSrcweir delete []pTabs; 135*cdf0e10cSrcweir delete []pScenarios; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir String __EXPORT ScUndoInsertCells::GetComment() const 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir return ScGlobal::GetRscString( pPasteUndo ? STR_UNDO_PASTE : STR_UNDO_INSERTCELLS ); 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir sal_Bool ScUndoInsertCells::Merge( SfxUndoAction* pNextAction ) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir // If a paste undo action has already been added, append (detective) action there. 146*cdf0e10cSrcweir if ( pPasteUndo ) 147*cdf0e10cSrcweir return pPasteUndo->Merge( pNextAction ); 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir if ( bPartOfPaste && pNextAction->ISA( ScUndoWrapper ) ) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir ScUndoWrapper* pWrapper = (ScUndoWrapper*)pNextAction; 152*cdf0e10cSrcweir SfxUndoAction* pWrappedAction = pWrapper->GetWrappedUndo(); 153*cdf0e10cSrcweir if ( pWrappedAction && pWrappedAction->ISA( ScUndoPaste ) ) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir // Store paste action if this is part of paste with inserting cells. 156*cdf0e10cSrcweir // A list action isn't used because Repeat wouldn't work (insert wrong cells). 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir pPasteUndo = pWrappedAction; 159*cdf0e10cSrcweir pWrapper->ForgetWrappedUndo(); // pWrapper is deleted by UndoManager 160*cdf0e10cSrcweir return sal_True; 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir // Call base class for detective handling 165*cdf0e10cSrcweir return ScMoveUndo::Merge( pNextAction ); 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir void ScUndoInsertCells::SetChangeTrack() 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); 171*cdf0e10cSrcweir if ( pChangeTrack ) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir pChangeTrack->AppendInsert( aEffRange ); 174*cdf0e10cSrcweir nEndChangeAction = pChangeTrack->GetActionMax(); 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir else 177*cdf0e10cSrcweir nEndChangeAction = 0; 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir void ScUndoInsertCells::DoChange( const sal_Bool bUndo ) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 183*cdf0e10cSrcweir SCTAB i; 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir if ( bUndo ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); 188*cdf0e10cSrcweir if ( pChangeTrack ) 189*cdf0e10cSrcweir pChangeTrack->Undo( nEndChangeAction, nEndChangeAction ); 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir else 192*cdf0e10cSrcweir SetChangeTrack(); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir // refresh of merged cells has to be after inserting/deleting 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir switch (eCmd) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir case INS_INSROWS: 199*cdf0e10cSrcweir case INS_CELLSDOWN: 200*cdf0e10cSrcweir for( i=0; i<nCount; i++ ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir if (bUndo) 203*cdf0e10cSrcweir pDoc->DeleteRow( aEffRange.aStart.Col(), pTabs[i], aEffRange.aEnd.Col(), pTabs[i]+pScenarios[i], 204*cdf0e10cSrcweir aEffRange.aStart.Row(), static_cast<SCSIZE>(aEffRange.aEnd.Row()-aEffRange.aStart.Row()+1)); 205*cdf0e10cSrcweir else 206*cdf0e10cSrcweir pDoc->InsertRow( aEffRange.aStart.Col(), pTabs[i], aEffRange.aEnd.Col(), pTabs[i]+pScenarios[i], 207*cdf0e10cSrcweir aEffRange.aStart.Row(), static_cast<SCSIZE>(aEffRange.aEnd.Row()-aEffRange.aStart.Row()+1)); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir break; 210*cdf0e10cSrcweir case INS_INSCOLS: 211*cdf0e10cSrcweir case INS_CELLSRIGHT: 212*cdf0e10cSrcweir for( i=0; i<nCount; i++ ) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir if (bUndo) 215*cdf0e10cSrcweir pDoc->DeleteCol( aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i], 216*cdf0e10cSrcweir aEffRange.aStart.Col(), static_cast<SCSIZE>(aEffRange.aEnd.Col()-aEffRange.aStart.Col()+1)); 217*cdf0e10cSrcweir else 218*cdf0e10cSrcweir pDoc->InsertCol( aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i], 219*cdf0e10cSrcweir aEffRange.aStart.Col(), static_cast<SCSIZE>(aEffRange.aEnd.Col()-aEffRange.aStart.Col()+1)); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir break; 222*cdf0e10cSrcweir default: 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir // added to avoid warnings 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir ScRange aWorkRange( aEffRange ); 229*cdf0e10cSrcweir if ( eCmd == INS_CELLSRIGHT ) // only "shift right" requires refresh of the moved area 230*cdf0e10cSrcweir aWorkRange.aEnd.SetCol(MAXCOL); 231*cdf0e10cSrcweir for( i=0; i<nCount; i++ ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir if ( pDoc->HasAttrib( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), pTabs[i], 234*cdf0e10cSrcweir aWorkRange.aEnd.Col(), aWorkRange.aEnd.Row(), pTabs[i], HASATTR_MERGED ) ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir SCCOL nEndCol = aWorkRange.aEnd.Col(); 237*cdf0e10cSrcweir SCROW nEndRow = aWorkRange.aEnd.Row(); 238*cdf0e10cSrcweir pDoc->ExtendMerge( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), nEndCol, nEndRow, pTabs[i], sal_True ); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir //? Undo fuer herausgeschobene Attribute ? 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir sal_uInt16 nPaint = PAINT_GRID; 245*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 246*cdf0e10cSrcweir switch (eCmd) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir case INS_INSROWS: 249*cdf0e10cSrcweir nPaint |= PAINT_LEFT; 250*cdf0e10cSrcweir aWorkRange.aEnd.SetRow(MAXROW); 251*cdf0e10cSrcweir break; 252*cdf0e10cSrcweir case INS_CELLSDOWN: 253*cdf0e10cSrcweir for( i=0; i<nCount; i++ ) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir aWorkRange.aEnd.SetRow(MAXROW); 256*cdf0e10cSrcweir if ( pDocShell->AdjustRowHeight( aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), pTabs[i] )) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir aWorkRange.aStart.SetCol(0); 259*cdf0e10cSrcweir aWorkRange.aEnd.SetCol(MAXCOL); 260*cdf0e10cSrcweir nPaint |= PAINT_LEFT; 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir break; 264*cdf0e10cSrcweir case INS_INSCOLS: 265*cdf0e10cSrcweir nPaint |= PAINT_TOP; // obere Leiste 266*cdf0e10cSrcweir case INS_CELLSRIGHT: 267*cdf0e10cSrcweir for( i=0; i<nCount; i++ ) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir aWorkRange.aEnd.SetCol(MAXCOL); // bis ganz nach rechts 270*cdf0e10cSrcweir if ( pDocShell->AdjustRowHeight( aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), pTabs[i]) ) 271*cdf0e10cSrcweir { // AdjustDraw zeichnet PAINT_TOP nicht, 272*cdf0e10cSrcweir aWorkRange.aStart.SetCol(0); // daher so geloest 273*cdf0e10cSrcweir aWorkRange.aEnd.SetRow(MAXROW); 274*cdf0e10cSrcweir nPaint |= PAINT_LEFT; 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir break; 278*cdf0e10cSrcweir default: 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir // added to avoid warnings 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir for( i=0; i<nCount; i++ ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir pDocShell->PostPaint( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), pTabs[i], 287*cdf0e10cSrcweir aWorkRange.aEnd.Col(), aWorkRange.aEnd.Row(), pTabs[i]+pScenarios[i], nPaint ); 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir pDocShell->PostDataChanged(); 290*cdf0e10cSrcweir if (pViewShell) 291*cdf0e10cSrcweir pViewShell->CellContentChanged(); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir void __EXPORT ScUndoInsertCells::Undo() 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir if ( pPasteUndo ) 297*cdf0e10cSrcweir pPasteUndo->Undo(); // undo paste first 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir WaitObject aWait( pDocShell->GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference 300*cdf0e10cSrcweir BeginUndo(); 301*cdf0e10cSrcweir DoChange( sal_True ); 302*cdf0e10cSrcweir EndUndo(); 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir void __EXPORT ScUndoInsertCells::Redo() 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir WaitObject aWait( pDocShell->GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference 308*cdf0e10cSrcweir BeginRedo(); 309*cdf0e10cSrcweir DoChange( sal_False ); 310*cdf0e10cSrcweir EndRedo(); 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir if ( pPasteUndo ) 313*cdf0e10cSrcweir pPasteUndo->Redo(); // redo paste last 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir void __EXPORT ScUndoInsertCells::Repeat(SfxRepeatTarget& rTarget) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir if ( pPasteUndo ) 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir // #94115# Repeat for paste with inserting cells is handled completely 323*cdf0e10cSrcweir // by the Paste undo action 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir pPasteUndo->Repeat( rTarget ); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir else 328*cdf0e10cSrcweir ((ScTabViewTarget&)rTarget).GetViewShell()->InsertCells( eCmd, sal_True ); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoInsertCells::CanRepeat(SfxRepeatTarget& rTarget) const 333*cdf0e10cSrcweir { 334*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir // ----------------------------------------------------------------------- 339*cdf0e10cSrcweir // 340*cdf0e10cSrcweir // Zellen loeschen 341*cdf0e10cSrcweir // Zeilen loeschen 342*cdf0e10cSrcweir // einzeln oder Block 343*cdf0e10cSrcweir // 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir ScUndoDeleteCells::ScUndoDeleteCells( ScDocShell* pNewDocShell, 346*cdf0e10cSrcweir const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios, 347*cdf0e10cSrcweir DelCellCmd eNewCmd, ScDocument* pUndoDocument, ScRefUndoData* pRefData ) : 348*cdf0e10cSrcweir ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ), 349*cdf0e10cSrcweir aEffRange( rRange ), 350*cdf0e10cSrcweir nCount( nNewCount ), 351*cdf0e10cSrcweir pTabs( pNewTabs ), 352*cdf0e10cSrcweir pScenarios( pNewScenarios ), 353*cdf0e10cSrcweir eCmd( eNewCmd ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir if (eCmd == DEL_DELROWS) // gaze Zeilen? 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir aEffRange.aStart.SetCol(0); 358*cdf0e10cSrcweir aEffRange.aEnd.SetCol(MAXCOL); 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir if (eCmd == DEL_DELCOLS) // ganze Spalten? 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir aEffRange.aStart.SetRow(0); 364*cdf0e10cSrcweir aEffRange.aEnd.SetRow(MAXROW); 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir SetChangeTrack(); 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir __EXPORT ScUndoDeleteCells::~ScUndoDeleteCells() 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir delete []pTabs; 373*cdf0e10cSrcweir delete []pScenarios; 374*cdf0e10cSrcweir } 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir String __EXPORT ScUndoDeleteCells::GetComment() const 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_DELETECELLS ); // "Loeschen" 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir void ScUndoDeleteCells::SetChangeTrack() 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); 384*cdf0e10cSrcweir if ( pChangeTrack ) 385*cdf0e10cSrcweir pChangeTrack->AppendDeleteRange( aEffRange, pRefUndoDoc, 386*cdf0e10cSrcweir nStartChangeAction, nEndChangeAction ); 387*cdf0e10cSrcweir else 388*cdf0e10cSrcweir nStartChangeAction = nEndChangeAction = 0; 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir void ScUndoDeleteCells::DoChange( const sal_Bool bUndo ) 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 394*cdf0e10cSrcweir SCTAB i; 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir if ( bUndo ) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); 399*cdf0e10cSrcweir if ( pChangeTrack ) 400*cdf0e10cSrcweir pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir else 403*cdf0e10cSrcweir SetChangeTrack(); 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir // Ausfuehren 406*cdf0e10cSrcweir switch (eCmd) 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir case DEL_DELROWS: 409*cdf0e10cSrcweir case DEL_CELLSUP: 410*cdf0e10cSrcweir for( i=0; i<nCount; i++ ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir if (bUndo) 413*cdf0e10cSrcweir pDoc->InsertRow( aEffRange.aStart.Col(), pTabs[i], aEffRange.aEnd.Col(), pTabs[i]+pScenarios[i], 414*cdf0e10cSrcweir aEffRange.aStart.Row(), static_cast<SCSIZE>(aEffRange.aEnd.Row()-aEffRange.aStart.Row()+1)); 415*cdf0e10cSrcweir else 416*cdf0e10cSrcweir pDoc->DeleteRow( aEffRange.aStart.Col(), pTabs[i], aEffRange.aEnd.Col(), pTabs[i]+pScenarios[i], 417*cdf0e10cSrcweir aEffRange.aStart.Row(), static_cast<SCSIZE>(aEffRange.aEnd.Row()-aEffRange.aStart.Row()+1)); 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir break; 420*cdf0e10cSrcweir case DEL_DELCOLS: 421*cdf0e10cSrcweir case DEL_CELLSLEFT: 422*cdf0e10cSrcweir for( i=0; i<nCount; i++ ) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir if (bUndo) 425*cdf0e10cSrcweir pDoc->InsertCol( aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i], 426*cdf0e10cSrcweir aEffRange.aStart.Col(), static_cast<SCSIZE>(aEffRange.aEnd.Col()-aEffRange.aStart.Col()+1)); 427*cdf0e10cSrcweir else 428*cdf0e10cSrcweir pDoc->DeleteCol( aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i], 429*cdf0e10cSrcweir aEffRange.aStart.Col(), static_cast<SCSIZE>(aEffRange.aEnd.Col()-aEffRange.aStart.Col()+1)); 430*cdf0e10cSrcweir } 431*cdf0e10cSrcweir break; 432*cdf0e10cSrcweir default: 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir // added to avoid warnings 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir // bei Undo Referenzen wiederherstellen 439*cdf0e10cSrcweir for( i=0; i<nCount && bUndo; i++ ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir pRefUndoDoc->CopyToDocument( aEffRange.aStart.Col(), aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Col(), aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i], 442*cdf0e10cSrcweir IDF_ALL | IDF_NOCAPTIONS, sal_False, pDoc ); 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir ScRange aWorkRange( aEffRange ); 446*cdf0e10cSrcweir if ( eCmd == DEL_CELLSLEFT ) // only "shift left" requires refresh of the moved area 447*cdf0e10cSrcweir aWorkRange.aEnd.SetCol(MAXCOL); 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir for( i=0; i<nCount; i++ ) 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir if ( pDoc->HasAttrib( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), pTabs[i], 452*cdf0e10cSrcweir aWorkRange.aEnd.Col(), aWorkRange.aEnd.Row(), pTabs[i], HASATTR_MERGED | HASATTR_OVERLAPPED ) ) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir // #i51445# old merge flag attributes must be deleted also for single cells, 455*cdf0e10cSrcweir // not only for whole columns/rows 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir if ( !bUndo ) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir if ( eCmd==DEL_DELCOLS || eCmd==DEL_CELLSLEFT ) 460*cdf0e10cSrcweir aWorkRange.aEnd.SetCol(MAXCOL); 461*cdf0e10cSrcweir if ( eCmd==DEL_DELROWS || eCmd==DEL_CELLSUP ) 462*cdf0e10cSrcweir aWorkRange.aEnd.SetRow(MAXROW); 463*cdf0e10cSrcweir ScMarkData aMarkData; 464*cdf0e10cSrcweir aMarkData.SelectOneTable( aWorkRange.aStart.Tab() ); 465*cdf0e10cSrcweir ScPatternAttr aPattern( pDoc->GetPool() ); 466*cdf0e10cSrcweir aPattern.GetItemSet().Put( ScMergeFlagAttr() ); 467*cdf0e10cSrcweir pDoc->ApplyPatternArea( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), 468*cdf0e10cSrcweir aWorkRange.aEnd.Col(), aWorkRange.aEnd.Row(), 469*cdf0e10cSrcweir aMarkData, aPattern ); 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir SCCOL nEndCol = aWorkRange.aEnd.Col(); 473*cdf0e10cSrcweir SCROW nEndRow = aWorkRange.aEnd.Row(); 474*cdf0e10cSrcweir pDoc->ExtendMerge( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), nEndCol, nEndRow, pTabs[i], sal_True ); 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir // Zeichnen 479*cdf0e10cSrcweir sal_uInt16 nPaint = PAINT_GRID; 480*cdf0e10cSrcweir switch (eCmd) 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir case DEL_DELROWS: 483*cdf0e10cSrcweir nPaint |= PAINT_LEFT; 484*cdf0e10cSrcweir aWorkRange.aEnd.SetRow(MAXROW); 485*cdf0e10cSrcweir break; 486*cdf0e10cSrcweir case DEL_CELLSUP: 487*cdf0e10cSrcweir for( i=0; i<nCount; i++ ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir aWorkRange.aEnd.SetRow(MAXROW); 490*cdf0e10cSrcweir if ( pDocShell->AdjustRowHeight( aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), pTabs[i] )) 491*cdf0e10cSrcweir { 492*cdf0e10cSrcweir aWorkRange.aStart.SetCol(0); 493*cdf0e10cSrcweir aWorkRange.aEnd.SetCol(MAXCOL); 494*cdf0e10cSrcweir nPaint |= PAINT_LEFT; 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir break; 498*cdf0e10cSrcweir case DEL_DELCOLS: 499*cdf0e10cSrcweir nPaint |= PAINT_TOP; // obere Leiste 500*cdf0e10cSrcweir case DEL_CELLSLEFT: 501*cdf0e10cSrcweir for( i=0; i<nCount; i++ ) 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir aWorkRange.aEnd.SetCol(MAXCOL); // bis ganz nach rechts 504*cdf0e10cSrcweir if ( pDocShell->AdjustRowHeight( aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), pTabs[i] ) ) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir aWorkRange.aStart.SetCol(0); 507*cdf0e10cSrcweir aWorkRange.aEnd.SetRow(MAXROW); 508*cdf0e10cSrcweir nPaint |= PAINT_LEFT; 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir break; 512*cdf0e10cSrcweir default: 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir // added to avoid warnings 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir for( i=0; i<nCount; i++ ) 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir pDocShell->PostPaint( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), pTabs[i], 521*cdf0e10cSrcweir aWorkRange.aEnd.Col(), aWorkRange.aEnd.Row(), pTabs[i]+pScenarios[i], nPaint, SC_PF_LINES ); 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir // Markierung erst nach EndUndo 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir pDocShell->PostDataChanged(); 526*cdf0e10cSrcweir // CellContentChanged kommt mit der Markierung 527*cdf0e10cSrcweir } 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir void __EXPORT ScUndoDeleteCells::Undo() 530*cdf0e10cSrcweir { 531*cdf0e10cSrcweir WaitObject aWait( pDocShell->GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference 532*cdf0e10cSrcweir BeginUndo(); 533*cdf0e10cSrcweir DoChange( sal_True ); 534*cdf0e10cSrcweir EndUndo(); 535*cdf0e10cSrcweir SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir // Markierung erst nach EndUndo 538*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 539*cdf0e10cSrcweir if (pViewShell) 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir for( SCTAB i=0; i<nCount; i++ ) 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir pViewShell->MarkRange( ScRange(aEffRange.aStart.Col(), aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Col(), aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i]) ); 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir void __EXPORT ScUndoDeleteCells::Redo() 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir WaitObject aWait( pDocShell->GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference 551*cdf0e10cSrcweir BeginRedo(); 552*cdf0e10cSrcweir DoChange( sal_False); 553*cdf0e10cSrcweir EndRedo(); 554*cdf0e10cSrcweir SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 557*cdf0e10cSrcweir if (pViewShell) 558*cdf0e10cSrcweir pViewShell->DoneBlockMode(); // aktuelle weg 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir void __EXPORT ScUndoDeleteCells::Repeat(SfxRepeatTarget& rTarget) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 564*cdf0e10cSrcweir ((ScTabViewTarget&)rTarget).GetViewShell()->DeleteCells( eCmd, sal_True ); 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoDeleteCells::CanRepeat(SfxRepeatTarget& rTarget) const 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir // ----------------------------------------------------------------------- 574*cdf0e10cSrcweir // 575*cdf0e10cSrcweir // Zellen loeschen auf Mehrfachselektion 576*cdf0e10cSrcweir // 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir ScUndoDeleteMulti::ScUndoDeleteMulti( ScDocShell* pNewDocShell, 579*cdf0e10cSrcweir sal_Bool bNewRows, sal_Bool bNeedsRefresh, SCTAB nNewTab, 580*cdf0e10cSrcweir const SCCOLROW* pRng, SCCOLROW nRngCnt, 581*cdf0e10cSrcweir ScDocument* pUndoDocument, ScRefUndoData* pRefData ) : 582*cdf0e10cSrcweir ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ), 583*cdf0e10cSrcweir bRows( bNewRows ), 584*cdf0e10cSrcweir bRefresh( bNeedsRefresh ), 585*cdf0e10cSrcweir nTab( nNewTab ), 586*cdf0e10cSrcweir nRangeCnt( nRngCnt ) 587*cdf0e10cSrcweir { 588*cdf0e10cSrcweir pRanges = new SCCOLROW[ 2 * nRangeCnt ]; 589*cdf0e10cSrcweir memcpy(pRanges,pRng,nRangeCnt*2*sizeof(SCCOLROW)); 590*cdf0e10cSrcweir SetChangeTrack(); 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir __EXPORT ScUndoDeleteMulti::~ScUndoDeleteMulti() 594*cdf0e10cSrcweir { 595*cdf0e10cSrcweir delete [] pRanges; 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir String __EXPORT ScUndoDeleteMulti::GetComment() const 599*cdf0e10cSrcweir { 600*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_DELETECELLS ); // wie DeleteCells 601*cdf0e10cSrcweir } 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir void ScUndoDeleteMulti::DoChange() const 604*cdf0e10cSrcweir { 605*cdf0e10cSrcweir SCCOL nStartCol; 606*cdf0e10cSrcweir SCROW nStartRow; 607*cdf0e10cSrcweir sal_uInt16 nPaint; 608*cdf0e10cSrcweir if (bRows) 609*cdf0e10cSrcweir { 610*cdf0e10cSrcweir nStartCol = 0; 611*cdf0e10cSrcweir nStartRow = static_cast<SCROW>(pRanges[0]); 612*cdf0e10cSrcweir nPaint = PAINT_GRID | PAINT_LEFT; 613*cdf0e10cSrcweir } 614*cdf0e10cSrcweir else 615*cdf0e10cSrcweir { 616*cdf0e10cSrcweir nStartCol = static_cast<SCCOL>(pRanges[0]); 617*cdf0e10cSrcweir nStartRow = 0; 618*cdf0e10cSrcweir nPaint = PAINT_GRID | PAINT_TOP; 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir if ( bRefresh ) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 624*cdf0e10cSrcweir SCCOL nEndCol = MAXCOL; 625*cdf0e10cSrcweir SCROW nEndRow = MAXROW; 626*cdf0e10cSrcweir pDoc->RemoveFlagsTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, SC_MF_HOR | SC_MF_VER ); 627*cdf0e10cSrcweir pDoc->ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab, sal_True ); 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir pDocShell->PostPaint( nStartCol, nStartRow, nTab, MAXCOL, MAXROW, nTab, nPaint ); 631*cdf0e10cSrcweir pDocShell->PostDataChanged(); 632*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 633*cdf0e10cSrcweir if (pViewShell) 634*cdf0e10cSrcweir pViewShell->CellContentChanged(); 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir ShowTable( nTab ); 637*cdf0e10cSrcweir } 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir void ScUndoDeleteMulti::SetChangeTrack() 640*cdf0e10cSrcweir { 641*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); 642*cdf0e10cSrcweir if ( pChangeTrack ) 643*cdf0e10cSrcweir { 644*cdf0e10cSrcweir nStartChangeAction = pChangeTrack->GetActionMax() + 1; 645*cdf0e10cSrcweir ScRange aRange( 0, 0, nTab, 0, 0, nTab ); 646*cdf0e10cSrcweir if ( bRows ) 647*cdf0e10cSrcweir aRange.aEnd.SetCol( MAXCOL ); 648*cdf0e10cSrcweir else 649*cdf0e10cSrcweir aRange.aEnd.SetRow( MAXROW ); 650*cdf0e10cSrcweir // rueckwaerts loeschen 651*cdf0e10cSrcweir SCCOLROW* pOneRange = &pRanges[2*nRangeCnt]; 652*cdf0e10cSrcweir for ( SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++ ) 653*cdf0e10cSrcweir { 654*cdf0e10cSrcweir SCCOLROW nEnd = *(--pOneRange); 655*cdf0e10cSrcweir SCCOLROW nStart = *(--pOneRange); 656*cdf0e10cSrcweir if ( bRows ) 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir aRange.aStart.SetRow( nStart ); 659*cdf0e10cSrcweir aRange.aEnd.SetRow( nEnd ); 660*cdf0e10cSrcweir } 661*cdf0e10cSrcweir else 662*cdf0e10cSrcweir { 663*cdf0e10cSrcweir aRange.aStart.SetCol( static_cast<SCCOL>(nStart) ); 664*cdf0e10cSrcweir aRange.aEnd.SetCol( static_cast<SCCOL>(nEnd) ); 665*cdf0e10cSrcweir } 666*cdf0e10cSrcweir sal_uLong nDummyStart; 667*cdf0e10cSrcweir pChangeTrack->AppendDeleteRange( aRange, pRefUndoDoc, 668*cdf0e10cSrcweir nDummyStart, nEndChangeAction ); 669*cdf0e10cSrcweir } 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir else 672*cdf0e10cSrcweir nStartChangeAction = nEndChangeAction = 0; 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir void __EXPORT ScUndoDeleteMulti::Undo() 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir WaitObject aWait( pDocShell->GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference 678*cdf0e10cSrcweir BeginUndo(); 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 681*cdf0e10cSrcweir SCCOLROW* pOneRange; 682*cdf0e10cSrcweir SCCOLROW nRangeNo; 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir // rueckwaerts geloescht -> vorwaerts einfuegen 685*cdf0e10cSrcweir pOneRange = pRanges; 686*cdf0e10cSrcweir for (nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir SCCOLROW nStart = *(pOneRange++); 689*cdf0e10cSrcweir SCCOLROW nEnd = *(pOneRange++); 690*cdf0e10cSrcweir if (bRows) 691*cdf0e10cSrcweir pDoc->InsertRow( 0,nTab, MAXCOL,nTab, nStart,static_cast<SCSIZE>(nEnd-nStart+1) ); 692*cdf0e10cSrcweir else 693*cdf0e10cSrcweir pDoc->InsertCol( 0,nTab, MAXROW,nTab, static_cast<SCCOL>(nStart), static_cast<SCSIZE>(nEnd-nStart+1) ); 694*cdf0e10cSrcweir } 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir pOneRange = pRanges; 697*cdf0e10cSrcweir for (nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir SCCOLROW nStart = *(pOneRange++); 700*cdf0e10cSrcweir SCCOLROW nEnd = *(pOneRange++); 701*cdf0e10cSrcweir if (bRows) 702*cdf0e10cSrcweir pRefUndoDoc->CopyToDocument( 0,nStart,nTab, MAXCOL,nEnd,nTab, IDF_ALL,sal_False,pDoc ); 703*cdf0e10cSrcweir else 704*cdf0e10cSrcweir pRefUndoDoc->CopyToDocument( static_cast<SCCOL>(nStart),0,nTab, 705*cdf0e10cSrcweir static_cast<SCCOL>(nEnd),MAXROW,nTab, IDF_ALL,sal_False,pDoc ); 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); 709*cdf0e10cSrcweir if ( pChangeTrack ) 710*cdf0e10cSrcweir pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); 711*cdf0e10cSrcweir 712*cdf0e10cSrcweir DoChange(); 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir //! Markierung wieder einzeichnen 715*cdf0e10cSrcweir //! geht im Moment nicht, da keine Daten fuer Markierung vorhanden! 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir EndUndo(); 718*cdf0e10cSrcweir SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); 719*cdf0e10cSrcweir } 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir void __EXPORT ScUndoDeleteMulti::Redo() 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir WaitObject aWait( pDocShell->GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference 724*cdf0e10cSrcweir BeginRedo(); 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 727*cdf0e10cSrcweir 728*cdf0e10cSrcweir // rueckwaerts loeschen 729*cdf0e10cSrcweir SCCOLROW* pOneRange = &pRanges[2*nRangeCnt]; 730*cdf0e10cSrcweir for (SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++) 731*cdf0e10cSrcweir { 732*cdf0e10cSrcweir SCCOLROW nEnd = *(--pOneRange); 733*cdf0e10cSrcweir SCCOLROW nStart = *(--pOneRange); 734*cdf0e10cSrcweir if (bRows) 735*cdf0e10cSrcweir pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, nStart,static_cast<SCSIZE>(nEnd-nStart+1) ); 736*cdf0e10cSrcweir else 737*cdf0e10cSrcweir pDoc->DeleteCol( 0,nTab, MAXROW,nTab, static_cast<SCCOL>(nStart), static_cast<SCSIZE>(nEnd-nStart+1) ); 738*cdf0e10cSrcweir } 739*cdf0e10cSrcweir 740*cdf0e10cSrcweir SetChangeTrack(); 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir DoChange(); 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir //! Markierung loeschen, derzeit unnoetig (s.o.) 745*cdf0e10cSrcweir //! ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 746*cdf0e10cSrcweir //! if (pViewShell) 747*cdf0e10cSrcweir //! DoneBlockMode(); 748*cdf0e10cSrcweir 749*cdf0e10cSrcweir EndRedo(); 750*cdf0e10cSrcweir SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); 751*cdf0e10cSrcweir } 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir void __EXPORT ScUndoDeleteMulti::Repeat(SfxRepeatTarget& rTarget) 754*cdf0e10cSrcweir { 755*cdf0e10cSrcweir // DeleteCells, falls einfache Selektion 756*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 757*cdf0e10cSrcweir ((ScTabViewTarget&)rTarget).GetViewShell()->DeleteCells( DEL_DELROWS, sal_True ); 758*cdf0e10cSrcweir } 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoDeleteMulti::CanRepeat(SfxRepeatTarget& rTarget) const 761*cdf0e10cSrcweir { 762*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 763*cdf0e10cSrcweir } 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir // ----------------------------------------------------------------------- 767*cdf0e10cSrcweir // 768*cdf0e10cSrcweir // Ausschneiden (Cut) 769*cdf0e10cSrcweir // 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir ScUndoCut::ScUndoCut( ScDocShell* pNewDocShell, 772*cdf0e10cSrcweir ScRange aRange, ScAddress aOldEnd, const ScMarkData& rMark, 773*cdf0e10cSrcweir ScDocument* pNewUndoDoc ) : 774*cdf0e10cSrcweir ScBlockUndo( pNewDocShell, ScRange(aRange.aStart, aOldEnd), SC_UNDO_AUTOHEIGHT ), 775*cdf0e10cSrcweir aMarkData( rMark ), 776*cdf0e10cSrcweir pUndoDoc( pNewUndoDoc ), 777*cdf0e10cSrcweir aExtendedRange( aRange ) 778*cdf0e10cSrcweir { 779*cdf0e10cSrcweir SetChangeTrack(); 780*cdf0e10cSrcweir } 781*cdf0e10cSrcweir 782*cdf0e10cSrcweir __EXPORT ScUndoCut::~ScUndoCut() 783*cdf0e10cSrcweir { 784*cdf0e10cSrcweir delete pUndoDoc; 785*cdf0e10cSrcweir } 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir String __EXPORT ScUndoCut::GetComment() const 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_CUT ); // "Ausschneiden" 790*cdf0e10cSrcweir } 791*cdf0e10cSrcweir 792*cdf0e10cSrcweir void ScUndoCut::SetChangeTrack() 793*cdf0e10cSrcweir { 794*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); 795*cdf0e10cSrcweir if ( pChangeTrack ) 796*cdf0e10cSrcweir pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc, 797*cdf0e10cSrcweir nStartChangeAction, nEndChangeAction, SC_CACM_CUT ); 798*cdf0e10cSrcweir else 799*cdf0e10cSrcweir nStartChangeAction = nEndChangeAction = 0; 800*cdf0e10cSrcweir } 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir void ScUndoCut::DoChange( const sal_Bool bUndo ) 803*cdf0e10cSrcweir { 804*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 805*cdf0e10cSrcweir sal_uInt16 nExtFlags = 0; 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir // do not undo/redo objects and note captions, they are handled via drawing undo 808*cdf0e10cSrcweir sal_uInt16 nUndoFlags = (IDF_ALL & ~IDF_OBJECTS) | IDF_NOCAPTIONS; 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir if (bUndo) // nur bei Undo 811*cdf0e10cSrcweir { 812*cdf0e10cSrcweir // all sheets - CopyToDocument skips those that don't exist in pUndoDoc 813*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 814*cdf0e10cSrcweir ScRange aCopyRange = aExtendedRange; 815*cdf0e10cSrcweir aCopyRange.aStart.SetTab(0); 816*cdf0e10cSrcweir aCopyRange.aEnd.SetTab(nTabCount-1); 817*cdf0e10cSrcweir pUndoDoc->CopyToDocument( aCopyRange, nUndoFlags, sal_False, pDoc ); 818*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); 819*cdf0e10cSrcweir if ( pChangeTrack ) 820*cdf0e10cSrcweir pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); 821*cdf0e10cSrcweir } 822*cdf0e10cSrcweir else // nur bei Redo 823*cdf0e10cSrcweir { 824*cdf0e10cSrcweir pDocShell->UpdatePaintExt( nExtFlags, aExtendedRange ); 825*cdf0e10cSrcweir pDoc->DeleteArea( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(), 826*cdf0e10cSrcweir aBlockRange.aEnd.Col(), aBlockRange.aEnd.Row(), aMarkData, nUndoFlags ); 827*cdf0e10cSrcweir SetChangeTrack(); 828*cdf0e10cSrcweir } 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 831*cdf0e10cSrcweir if ( !( (pViewShell) && pViewShell->AdjustBlockHeight() ) ) 832*cdf0e10cSrcweir /*A*/ pDocShell->PostPaint( aExtendedRange, PAINT_GRID, nExtFlags ); 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir if ( !bUndo ) // draw redo after updating row heights 835*cdf0e10cSrcweir RedoSdrUndoAction( pDrawUndo ); //! include in ScBlockUndo? 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir pDocShell->PostDataChanged(); 838*cdf0e10cSrcweir if (pViewShell) 839*cdf0e10cSrcweir pViewShell->CellContentChanged(); 840*cdf0e10cSrcweir } 841*cdf0e10cSrcweir 842*cdf0e10cSrcweir void __EXPORT ScUndoCut::Undo() 843*cdf0e10cSrcweir { 844*cdf0e10cSrcweir BeginUndo(); 845*cdf0e10cSrcweir DoChange( sal_True ); 846*cdf0e10cSrcweir EndUndo(); 847*cdf0e10cSrcweir } 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir void __EXPORT ScUndoCut::Redo() 850*cdf0e10cSrcweir { 851*cdf0e10cSrcweir BeginRedo(); 852*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 853*cdf0e10cSrcweir EnableDrawAdjust( pDoc, sal_False ); //! include in ScBlockUndo? 854*cdf0e10cSrcweir DoChange( sal_False ); 855*cdf0e10cSrcweir EnableDrawAdjust( pDoc, sal_True ); //! include in ScBlockUndo? 856*cdf0e10cSrcweir EndRedo(); 857*cdf0e10cSrcweir } 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir void __EXPORT ScUndoCut::Repeat(SfxRepeatTarget& rTarget) 860*cdf0e10cSrcweir { 861*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 862*cdf0e10cSrcweir ((ScTabViewTarget&)rTarget).GetViewShell()->CutToClip( NULL, sal_True ); 863*cdf0e10cSrcweir } 864*cdf0e10cSrcweir 865*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoCut::CanRepeat(SfxRepeatTarget& rTarget) const 866*cdf0e10cSrcweir { 867*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 868*cdf0e10cSrcweir } 869*cdf0e10cSrcweir 870*cdf0e10cSrcweir 871*cdf0e10cSrcweir // ----------------------------------------------------------------------- 872*cdf0e10cSrcweir // 873*cdf0e10cSrcweir // Einfuegen (Paste) 874*cdf0e10cSrcweir // 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir ScUndoPaste::ScUndoPaste( ScDocShell* pNewDocShell, 877*cdf0e10cSrcweir SCCOL nStartX, SCROW nStartY, SCTAB nStartZ, 878*cdf0e10cSrcweir SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, 879*cdf0e10cSrcweir const ScMarkData& rMark, 880*cdf0e10cSrcweir ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, 881*cdf0e10cSrcweir sal_uInt16 nNewFlags, 882*cdf0e10cSrcweir ScRefUndoData* pRefData, 883*cdf0e10cSrcweir void* /* pFill1 */, void* /* pFill2 */, void* /* pFill3 */, 884*cdf0e10cSrcweir sal_Bool bRedoIsFilled, const ScUndoPasteOptions* pOptions ) : 885*cdf0e10cSrcweir ScBlockUndo( pNewDocShell, ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), SC_UNDO_SIMPLE ), 886*cdf0e10cSrcweir aMarkData( rMark ), 887*cdf0e10cSrcweir pUndoDoc( pNewUndoDoc ), 888*cdf0e10cSrcweir pRedoDoc( pNewRedoDoc ), 889*cdf0e10cSrcweir nFlags( nNewFlags ), 890*cdf0e10cSrcweir pRefUndoData( pRefData ), 891*cdf0e10cSrcweir pRefRedoData( NULL ), 892*cdf0e10cSrcweir bRedoFilled( bRedoIsFilled ) 893*cdf0e10cSrcweir { 894*cdf0e10cSrcweir // pFill1,pFill2,pFill3 are there so the ctor calls for simple paste (without cutting) 895*cdf0e10cSrcweir // don't have to be changed and branched for 641. 896*cdf0e10cSrcweir // They can be removed later. 897*cdf0e10cSrcweir 898*cdf0e10cSrcweir if ( !aMarkData.IsMarked() ) // no cell marked: 899*cdf0e10cSrcweir aMarkData.SetMarkArea( aBlockRange ); // mark paste block 900*cdf0e10cSrcweir 901*cdf0e10cSrcweir if ( pRefUndoData ) 902*cdf0e10cSrcweir pRefUndoData->DeleteUnchanged( pDocShell->GetDocument() ); 903*cdf0e10cSrcweir 904*cdf0e10cSrcweir if ( pOptions ) 905*cdf0e10cSrcweir aPasteOptions = *pOptions; // used only for Repeat 906*cdf0e10cSrcweir 907*cdf0e10cSrcweir SetChangeTrack(); 908*cdf0e10cSrcweir } 909*cdf0e10cSrcweir 910*cdf0e10cSrcweir __EXPORT ScUndoPaste::~ScUndoPaste() 911*cdf0e10cSrcweir { 912*cdf0e10cSrcweir delete pUndoDoc; 913*cdf0e10cSrcweir delete pRedoDoc; 914*cdf0e10cSrcweir delete pRefUndoData; 915*cdf0e10cSrcweir delete pRefRedoData; 916*cdf0e10cSrcweir } 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir String __EXPORT ScUndoPaste::GetComment() const 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_PASTE ); // "Einfuegen" 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir void ScUndoPaste::SetChangeTrack() 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); 926*cdf0e10cSrcweir if ( pChangeTrack && (nFlags & IDF_CONTENTS) ) 927*cdf0e10cSrcweir pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc, 928*cdf0e10cSrcweir nStartChangeAction, nEndChangeAction, SC_CACM_PASTE ); 929*cdf0e10cSrcweir else 930*cdf0e10cSrcweir nStartChangeAction = nEndChangeAction = 0; 931*cdf0e10cSrcweir } 932*cdf0e10cSrcweir 933*cdf0e10cSrcweir void ScUndoPaste::DoChange( const sal_Bool bUndo ) 934*cdf0e10cSrcweir { 935*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 936*cdf0e10cSrcweir 937*cdf0e10cSrcweir // RefUndoData for redo is created before first undo 938*cdf0e10cSrcweir // (with DeleteUnchanged after the DoUndo call) 939*cdf0e10cSrcweir sal_Bool bCreateRedoData = ( bUndo && pRefUndoData && !pRefRedoData ); 940*cdf0e10cSrcweir if ( bCreateRedoData ) 941*cdf0e10cSrcweir pRefRedoData = new ScRefUndoData( pDoc ); 942*cdf0e10cSrcweir 943*cdf0e10cSrcweir ScRefUndoData* pWorkRefData = bUndo ? pRefUndoData : pRefRedoData; 944*cdf0e10cSrcweir 945*cdf0e10cSrcweir // fuer Undo immer alle oder keine Inhalte sichern 946*cdf0e10cSrcweir sal_uInt16 nUndoFlags = IDF_NONE; 947*cdf0e10cSrcweir if (nFlags & IDF_CONTENTS) 948*cdf0e10cSrcweir nUndoFlags |= IDF_CONTENTS; 949*cdf0e10cSrcweir if (nFlags & IDF_ATTRIB) 950*cdf0e10cSrcweir nUndoFlags |= IDF_ATTRIB; 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir // do not undo/redo objects and note captions, they are handled via drawing undo 953*cdf0e10cSrcweir (nUndoFlags &= ~IDF_OBJECTS) |= IDF_NOCAPTIONS; 954*cdf0e10cSrcweir 955*cdf0e10cSrcweir sal_Bool bPaintAll = sal_False; 956*cdf0e10cSrcweir 957*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 958*cdf0e10cSrcweir 959*cdf0e10cSrcweir // marking is in ScBlockUndo... 960*cdf0e10cSrcweir ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockRange ); 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 963*cdf0e10cSrcweir if ( bUndo && !bRedoFilled ) 964*cdf0e10cSrcweir { 965*cdf0e10cSrcweir if (!pRedoDoc) 966*cdf0e10cSrcweir { 967*cdf0e10cSrcweir sal_Bool bColInfo = ( aBlockRange.aStart.Row()==0 && aBlockRange.aEnd.Row()==MAXROW ); 968*cdf0e10cSrcweir sal_Bool bRowInfo = ( aBlockRange.aStart.Col()==0 && aBlockRange.aEnd.Col()==MAXCOL ); 969*cdf0e10cSrcweir 970*cdf0e10cSrcweir pRedoDoc = new ScDocument( SCDOCMODE_UNDO ); 971*cdf0e10cSrcweir pRedoDoc->InitUndoSelected( pDoc, aMarkData, bColInfo, bRowInfo ); 972*cdf0e10cSrcweir } 973*cdf0e10cSrcweir // read "redo" data from the document in the first undo 974*cdf0e10cSrcweir // all sheets - CopyToDocument skips those that don't exist in pRedoDoc 975*cdf0e10cSrcweir ScRange aCopyRange = aBlockRange; 976*cdf0e10cSrcweir aCopyRange.aStart.SetTab(0); 977*cdf0e10cSrcweir aCopyRange.aEnd.SetTab(nTabCount-1); 978*cdf0e10cSrcweir pDoc->CopyToDocument( aCopyRange, nUndoFlags, sal_False, pRedoDoc ); 979*cdf0e10cSrcweir bRedoFilled = sal_True; 980*cdf0e10cSrcweir } 981*cdf0e10cSrcweir 982*cdf0e10cSrcweir sal_uInt16 nExtFlags = 0; 983*cdf0e10cSrcweir pDocShell->UpdatePaintExt( nExtFlags, aBlockRange ); 984*cdf0e10cSrcweir 985*cdf0e10cSrcweir aMarkData.MarkToMulti(); 986*cdf0e10cSrcweir pDoc->DeleteSelection( nUndoFlags, aMarkData ); 987*cdf0e10cSrcweir aMarkData.MarkToSimple(); 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir SCTAB nFirstSelected = aMarkData.GetFirstSelected(); 990*cdf0e10cSrcweir ScRange aTabSelectRange = aBlockRange; 991*cdf0e10cSrcweir SCTAB nTab; 992*cdf0e10cSrcweir 993*cdf0e10cSrcweir if ( !bUndo && pRedoDoc ) // Redo: UndoToDocument before handling RefData 994*cdf0e10cSrcweir { 995*cdf0e10cSrcweir aTabSelectRange.aStart.SetTab( nFirstSelected ); 996*cdf0e10cSrcweir aTabSelectRange.aEnd.SetTab( nFirstSelected ); 997*cdf0e10cSrcweir pRedoDoc->UndoToDocument( aTabSelectRange, nUndoFlags, sal_False, pDoc ); 998*cdf0e10cSrcweir for (nTab=0; nTab<nTabCount; nTab++) 999*cdf0e10cSrcweir if (nTab != nFirstSelected && aMarkData.GetTableSelect(nTab)) 1000*cdf0e10cSrcweir { 1001*cdf0e10cSrcweir aTabSelectRange.aStart.SetTab( nTab ); 1002*cdf0e10cSrcweir aTabSelectRange.aEnd.SetTab( nTab ); 1003*cdf0e10cSrcweir pRedoDoc->CopyToDocument( aTabSelectRange, nUndoFlags, sal_False, pDoc ); 1004*cdf0e10cSrcweir } 1005*cdf0e10cSrcweir } 1006*cdf0e10cSrcweir 1007*cdf0e10cSrcweir if (pWorkRefData) 1008*cdf0e10cSrcweir { 1009*cdf0e10cSrcweir pWorkRefData->DoUndo( pDoc, sal_True ); // sal_True = bSetChartRangeLists for SetChartListenerCollection 1010*cdf0e10cSrcweir if ( pDoc->RefreshAutoFilter( 0,0, MAXCOL,MAXROW, aBlockRange.aStart.Tab() ) ) 1011*cdf0e10cSrcweir bPaintAll = sal_True; 1012*cdf0e10cSrcweir } 1013*cdf0e10cSrcweir 1014*cdf0e10cSrcweir if ( bCreateRedoData && pRefRedoData ) 1015*cdf0e10cSrcweir pRefRedoData->DeleteUnchanged( pDoc ); 1016*cdf0e10cSrcweir 1017*cdf0e10cSrcweir if (bUndo) // Undo: UndoToDocument after handling RefData 1018*cdf0e10cSrcweir { 1019*cdf0e10cSrcweir aTabSelectRange.aStart.SetTab( nFirstSelected ); 1020*cdf0e10cSrcweir aTabSelectRange.aEnd.SetTab( nFirstSelected ); 1021*cdf0e10cSrcweir pUndoDoc->UndoToDocument( aTabSelectRange, nUndoFlags, sal_False, pDoc ); 1022*cdf0e10cSrcweir for (nTab=0; nTab<nTabCount; nTab++) 1023*cdf0e10cSrcweir if (nTab != nFirstSelected && aMarkData.GetTableSelect(nTab)) 1024*cdf0e10cSrcweir { 1025*cdf0e10cSrcweir aTabSelectRange.aStart.SetTab( nTab ); 1026*cdf0e10cSrcweir aTabSelectRange.aEnd.SetTab( nTab ); 1027*cdf0e10cSrcweir pUndoDoc->UndoToDocument( aTabSelectRange, nUndoFlags, sal_False, pDoc ); 1028*cdf0e10cSrcweir } 1029*cdf0e10cSrcweir } 1030*cdf0e10cSrcweir 1031*cdf0e10cSrcweir if ( bUndo ) 1032*cdf0e10cSrcweir { 1033*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); 1034*cdf0e10cSrcweir if ( pChangeTrack ) 1035*cdf0e10cSrcweir pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); 1036*cdf0e10cSrcweir } 1037*cdf0e10cSrcweir else 1038*cdf0e10cSrcweir SetChangeTrack(); 1039*cdf0e10cSrcweir 1040*cdf0e10cSrcweir ScRange aDrawRange( aBlockRange ); 1041*cdf0e10cSrcweir pDoc->ExtendMerge( aDrawRange, sal_True ); // only needed for single sheet (text/rtf etc.) 1042*cdf0e10cSrcweir sal_uInt16 nPaint = PAINT_GRID; 1043*cdf0e10cSrcweir if (bPaintAll) 1044*cdf0e10cSrcweir { 1045*cdf0e10cSrcweir aDrawRange.aStart.SetCol(0); 1046*cdf0e10cSrcweir aDrawRange.aStart.SetRow(0); 1047*cdf0e10cSrcweir aDrawRange.aEnd.SetCol(MAXCOL); 1048*cdf0e10cSrcweir aDrawRange.aEnd.SetRow(MAXROW); 1049*cdf0e10cSrcweir nPaint |= PAINT_TOP | PAINT_LEFT; 1050*cdf0e10cSrcweir /*A*/ if (pViewShell) 1051*cdf0e10cSrcweir pViewShell->AdjustBlockHeight(sal_False); 1052*cdf0e10cSrcweir } 1053*cdf0e10cSrcweir else 1054*cdf0e10cSrcweir { 1055*cdf0e10cSrcweir if ( aBlockRange.aStart.Row() == 0 && aBlockRange.aEnd.Row() == MAXROW ) // ganze Spalte 1056*cdf0e10cSrcweir { 1057*cdf0e10cSrcweir nPaint |= PAINT_TOP; 1058*cdf0e10cSrcweir aDrawRange.aEnd.SetCol(MAXCOL); 1059*cdf0e10cSrcweir } 1060*cdf0e10cSrcweir if ( aBlockRange.aStart.Col() == 0 && aBlockRange.aEnd.Col() == MAXCOL ) // ganze Zeile 1061*cdf0e10cSrcweir { 1062*cdf0e10cSrcweir nPaint |= PAINT_LEFT; 1063*cdf0e10cSrcweir aDrawRange.aEnd.SetRow(MAXROW); 1064*cdf0e10cSrcweir } 1065*cdf0e10cSrcweir /*A*/ if ((pViewShell) && pViewShell->AdjustBlockHeight(sal_False)) 1066*cdf0e10cSrcweir { 1067*cdf0e10cSrcweir aDrawRange.aStart.SetCol(0); 1068*cdf0e10cSrcweir aDrawRange.aStart.SetRow(0); 1069*cdf0e10cSrcweir aDrawRange.aEnd.SetCol(MAXCOL); 1070*cdf0e10cSrcweir aDrawRange.aEnd.SetRow(MAXROW); 1071*cdf0e10cSrcweir nPaint |= PAINT_LEFT; 1072*cdf0e10cSrcweir } 1073*cdf0e10cSrcweir pDocShell->UpdatePaintExt( nExtFlags, aDrawRange ); 1074*cdf0e10cSrcweir } 1075*cdf0e10cSrcweir 1076*cdf0e10cSrcweir if ( !bUndo ) // draw redo after updating row heights 1077*cdf0e10cSrcweir RedoSdrUndoAction( pDrawUndo ); //! include in ScBlockUndo? 1078*cdf0e10cSrcweir 1079*cdf0e10cSrcweir pDocShell->PostPaint( aDrawRange, nPaint, nExtFlags ); 1080*cdf0e10cSrcweir 1081*cdf0e10cSrcweir pDocShell->PostDataChanged(); 1082*cdf0e10cSrcweir if (pViewShell) 1083*cdf0e10cSrcweir pViewShell->CellContentChanged(); 1084*cdf0e10cSrcweir } 1085*cdf0e10cSrcweir 1086*cdf0e10cSrcweir void __EXPORT ScUndoPaste::Undo() 1087*cdf0e10cSrcweir { 1088*cdf0e10cSrcweir BeginUndo(); 1089*cdf0e10cSrcweir DoChange( sal_True ); 1090*cdf0e10cSrcweir ShowTable( aBlockRange ); 1091*cdf0e10cSrcweir EndUndo(); 1092*cdf0e10cSrcweir SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); 1093*cdf0e10cSrcweir } 1094*cdf0e10cSrcweir 1095*cdf0e10cSrcweir void __EXPORT ScUndoPaste::Redo() 1096*cdf0e10cSrcweir { 1097*cdf0e10cSrcweir BeginRedo(); 1098*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1099*cdf0e10cSrcweir EnableDrawAdjust( pDoc, sal_False ); //! include in ScBlockUndo? 1100*cdf0e10cSrcweir DoChange( sal_False ); 1101*cdf0e10cSrcweir EnableDrawAdjust( pDoc, sal_True ); //! include in ScBlockUndo? 1102*cdf0e10cSrcweir EndRedo(); 1103*cdf0e10cSrcweir SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); 1104*cdf0e10cSrcweir } 1105*cdf0e10cSrcweir 1106*cdf0e10cSrcweir void __EXPORT ScUndoPaste::Repeat(SfxRepeatTarget& rTarget) 1107*cdf0e10cSrcweir { 1108*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 1109*cdf0e10cSrcweir { 1110*cdf0e10cSrcweir ScTabViewShell* pViewSh = ((ScTabViewTarget&)rTarget).GetViewShell(); 1111*cdf0e10cSrcweir ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pViewSh->GetActiveWin() ); 1112*cdf0e10cSrcweir if (pOwnClip) 1113*cdf0e10cSrcweir { 1114*cdf0e10cSrcweir // #129384# keep a reference in case the clipboard is changed during PasteFromClip 1115*cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::datatransfer::XTransferable> aOwnClipRef( pOwnClip ); 1116*cdf0e10cSrcweir pViewSh->PasteFromClip( nFlags, pOwnClip->GetDocument(), 1117*cdf0e10cSrcweir aPasteOptions.nFunction, aPasteOptions.bSkipEmpty, aPasteOptions.bTranspose, 1118*cdf0e10cSrcweir aPasteOptions.bAsLink, aPasteOptions.eMoveMode, IDF_NONE, 1119*cdf0e10cSrcweir sal_True ); // allow warning dialog 1120*cdf0e10cSrcweir } 1121*cdf0e10cSrcweir } 1122*cdf0e10cSrcweir } 1123*cdf0e10cSrcweir 1124*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoPaste::CanRepeat(SfxRepeatTarget& rTarget) const 1125*cdf0e10cSrcweir { 1126*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 1127*cdf0e10cSrcweir } 1128*cdf0e10cSrcweir 1129*cdf0e10cSrcweir 1130*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1131*cdf0e10cSrcweir // 1132*cdf0e10cSrcweir // Verschieben/Kopieren (Drag & Drop) 1133*cdf0e10cSrcweir // 1134*cdf0e10cSrcweir 1135*cdf0e10cSrcweir ScUndoDragDrop::ScUndoDragDrop( ScDocShell* pNewDocShell, 1136*cdf0e10cSrcweir const ScRange& rRange, ScAddress aNewDestPos, sal_Bool bNewCut, 1137*cdf0e10cSrcweir ScDocument* pUndoDocument, ScRefUndoData* pRefData, sal_Bool bScenario ) : 1138*cdf0e10cSrcweir ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFFIRST ), 1139*cdf0e10cSrcweir aSrcRange( rRange ), 1140*cdf0e10cSrcweir bCut( bNewCut ), 1141*cdf0e10cSrcweir bKeepScenarioFlags( bScenario ) 1142*cdf0e10cSrcweir { 1143*cdf0e10cSrcweir ScAddress aDestEnd(aNewDestPos); 1144*cdf0e10cSrcweir aDestEnd.IncRow(aSrcRange.aEnd.Row() - aSrcRange.aStart.Row()); 1145*cdf0e10cSrcweir aDestEnd.IncCol(aSrcRange.aEnd.Col() - aSrcRange.aStart.Col()); 1146*cdf0e10cSrcweir aDestEnd.IncTab(aSrcRange.aEnd.Tab() - aSrcRange.aStart.Tab()); 1147*cdf0e10cSrcweir 1148*cdf0e10cSrcweir sal_Bool bIncludeFiltered = bCut; 1149*cdf0e10cSrcweir if ( !bIncludeFiltered ) 1150*cdf0e10cSrcweir { 1151*cdf0e10cSrcweir // find number of non-filtered rows 1152*cdf0e10cSrcweir SCROW nPastedCount = pDocShell->GetDocument()->CountNonFilteredRows( 1153*cdf0e10cSrcweir aSrcRange.aStart.Row(), aSrcRange.aEnd.Row(), aSrcRange.aStart.Tab()); 1154*cdf0e10cSrcweir 1155*cdf0e10cSrcweir if ( nPastedCount == 0 ) 1156*cdf0e10cSrcweir nPastedCount = 1; 1157*cdf0e10cSrcweir aDestEnd.SetRow( aNewDestPos.Row() + nPastedCount - 1 ); 1158*cdf0e10cSrcweir } 1159*cdf0e10cSrcweir 1160*cdf0e10cSrcweir aDestRange.aStart = aNewDestPos; 1161*cdf0e10cSrcweir aDestRange.aEnd = aDestEnd; 1162*cdf0e10cSrcweir 1163*cdf0e10cSrcweir SetChangeTrack(); 1164*cdf0e10cSrcweir } 1165*cdf0e10cSrcweir 1166*cdf0e10cSrcweir __EXPORT ScUndoDragDrop::~ScUndoDragDrop() 1167*cdf0e10cSrcweir { 1168*cdf0e10cSrcweir } 1169*cdf0e10cSrcweir 1170*cdf0e10cSrcweir String __EXPORT ScUndoDragDrop::GetComment() const 1171*cdf0e10cSrcweir { // "Verschieben" : "Kopieren" 1172*cdf0e10cSrcweir return bCut ? 1173*cdf0e10cSrcweir ScGlobal::GetRscString( STR_UNDO_MOVE ) : 1174*cdf0e10cSrcweir ScGlobal::GetRscString( STR_UNDO_COPY ); 1175*cdf0e10cSrcweir } 1176*cdf0e10cSrcweir 1177*cdf0e10cSrcweir void ScUndoDragDrop::SetChangeTrack() 1178*cdf0e10cSrcweir { 1179*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack(); 1180*cdf0e10cSrcweir if ( pChangeTrack ) 1181*cdf0e10cSrcweir { 1182*cdf0e10cSrcweir if ( bCut ) 1183*cdf0e10cSrcweir { 1184*cdf0e10cSrcweir nStartChangeAction = pChangeTrack->GetActionMax() + 1; 1185*cdf0e10cSrcweir pChangeTrack->AppendMove( aSrcRange, aDestRange, pRefUndoDoc ); 1186*cdf0e10cSrcweir nEndChangeAction = pChangeTrack->GetActionMax(); 1187*cdf0e10cSrcweir } 1188*cdf0e10cSrcweir else 1189*cdf0e10cSrcweir pChangeTrack->AppendContentRange( aDestRange, pRefUndoDoc, 1190*cdf0e10cSrcweir nStartChangeAction, nEndChangeAction ); 1191*cdf0e10cSrcweir } 1192*cdf0e10cSrcweir else 1193*cdf0e10cSrcweir nStartChangeAction = nEndChangeAction = 0; 1194*cdf0e10cSrcweir } 1195*cdf0e10cSrcweir 1196*cdf0e10cSrcweir void ScUndoDragDrop::PaintArea( ScRange aRange, sal_uInt16 nExtFlags ) const 1197*cdf0e10cSrcweir { 1198*cdf0e10cSrcweir sal_uInt16 nPaint = PAINT_GRID; 1199*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 1200*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1201*cdf0e10cSrcweir 1202*cdf0e10cSrcweir if (pViewShell) 1203*cdf0e10cSrcweir { 1204*cdf0e10cSrcweir VirtualDevice aVirtDev; 1205*cdf0e10cSrcweir ScViewData* pViewData = pViewShell->GetViewData(); 1206*cdf0e10cSrcweir 1207*cdf0e10cSrcweir if ( pDoc->SetOptimalHeight( aRange.aStart.Row(), aRange.aEnd.Row(), 1208*cdf0e10cSrcweir aRange.aStart.Tab(), 0, &aVirtDev, 1209*cdf0e10cSrcweir pViewData->GetPPTX(), pViewData->GetPPTY(), 1210*cdf0e10cSrcweir pViewData->GetZoomX(), pViewData->GetZoomY(), 1211*cdf0e10cSrcweir sal_False ) ) 1212*cdf0e10cSrcweir { 1213*cdf0e10cSrcweir aRange.aStart.SetCol(0); 1214*cdf0e10cSrcweir aRange.aEnd.SetCol(MAXCOL); 1215*cdf0e10cSrcweir aRange.aEnd.SetRow(MAXROW); 1216*cdf0e10cSrcweir nPaint |= PAINT_LEFT; 1217*cdf0e10cSrcweir } 1218*cdf0e10cSrcweir } 1219*cdf0e10cSrcweir 1220*cdf0e10cSrcweir if ( bKeepScenarioFlags ) 1221*cdf0e10cSrcweir { 1222*cdf0e10cSrcweir // Szenarien mitkopiert -> auch Szenario-Rahmen painten 1223*cdf0e10cSrcweir aRange.aStart.SetCol(0); 1224*cdf0e10cSrcweir aRange.aStart.SetRow(0); 1225*cdf0e10cSrcweir aRange.aEnd.SetCol(MAXCOL); 1226*cdf0e10cSrcweir aRange.aEnd.SetRow(MAXROW); 1227*cdf0e10cSrcweir } 1228*cdf0e10cSrcweir 1229*cdf0e10cSrcweir // column/row info (width/height) included if whole columns/rows were copied 1230*cdf0e10cSrcweir if ( aSrcRange.aStart.Col() == 0 && aSrcRange.aEnd.Col() == MAXCOL ) 1231*cdf0e10cSrcweir { 1232*cdf0e10cSrcweir nPaint |= PAINT_LEFT; 1233*cdf0e10cSrcweir aRange.aEnd.SetRow(MAXROW); 1234*cdf0e10cSrcweir } 1235*cdf0e10cSrcweir if ( aSrcRange.aStart.Row() == 0 && aSrcRange.aEnd.Row() == MAXROW ) 1236*cdf0e10cSrcweir { 1237*cdf0e10cSrcweir nPaint |= PAINT_TOP; 1238*cdf0e10cSrcweir aRange.aEnd.SetCol(MAXCOL); 1239*cdf0e10cSrcweir } 1240*cdf0e10cSrcweir 1241*cdf0e10cSrcweir pDocShell->PostPaint( aRange, nPaint, nExtFlags ); 1242*cdf0e10cSrcweir } 1243*cdf0e10cSrcweir 1244*cdf0e10cSrcweir 1245*cdf0e10cSrcweir void ScUndoDragDrop::DoUndo( ScRange aRange ) const 1246*cdf0e10cSrcweir { 1247*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1248*cdf0e10cSrcweir 1249*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); 1250*cdf0e10cSrcweir if ( pChangeTrack ) 1251*cdf0e10cSrcweir pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); 1252*cdf0e10cSrcweir 1253*cdf0e10cSrcweir //? DB-Areas vor Daten, damit bei ExtendMerge die Autofilter-Knoepfe stimmen 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir ScRange aPaintRange = aRange; 1256*cdf0e10cSrcweir pDoc->ExtendMerge( aPaintRange ); // before deleting 1257*cdf0e10cSrcweir 1258*cdf0e10cSrcweir sal_uInt16 nExtFlags = 0; 1259*cdf0e10cSrcweir pDocShell->UpdatePaintExt( nExtFlags, aPaintRange ); 1260*cdf0e10cSrcweir 1261*cdf0e10cSrcweir // do not undo objects and note captions, they are handled via drawing undo 1262*cdf0e10cSrcweir sal_uInt16 nUndoFlags = (IDF_ALL & ~IDF_OBJECTS) | IDF_NOCAPTIONS; 1263*cdf0e10cSrcweir 1264*cdf0e10cSrcweir pDoc->DeleteAreaTab( aRange, nUndoFlags ); 1265*cdf0e10cSrcweir pRefUndoDoc->CopyToDocument( aRange, nUndoFlags, sal_False, pDoc ); 1266*cdf0e10cSrcweir if ( pDoc->HasAttrib( aRange, HASATTR_MERGED ) ) 1267*cdf0e10cSrcweir pDoc->ExtendMerge( aRange, sal_True ); 1268*cdf0e10cSrcweir 1269*cdf0e10cSrcweir aPaintRange.aEnd.SetCol( Max( aPaintRange.aEnd.Col(), aRange.aEnd.Col() ) ); 1270*cdf0e10cSrcweir aPaintRange.aEnd.SetRow( Max( aPaintRange.aEnd.Row(), aRange.aEnd.Row() ) ); 1271*cdf0e10cSrcweir 1272*cdf0e10cSrcweir pDocShell->UpdatePaintExt( nExtFlags, aPaintRange ); 1273*cdf0e10cSrcweir PaintArea( aPaintRange, nExtFlags ); 1274*cdf0e10cSrcweir } 1275*cdf0e10cSrcweir 1276*cdf0e10cSrcweir void __EXPORT ScUndoDragDrop::Undo() 1277*cdf0e10cSrcweir { 1278*cdf0e10cSrcweir BeginUndo(); 1279*cdf0e10cSrcweir DoUndo(aDestRange); 1280*cdf0e10cSrcweir if (bCut) 1281*cdf0e10cSrcweir DoUndo(aSrcRange); 1282*cdf0e10cSrcweir EndUndo(); 1283*cdf0e10cSrcweir SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); 1284*cdf0e10cSrcweir } 1285*cdf0e10cSrcweir 1286*cdf0e10cSrcweir void __EXPORT ScUndoDragDrop::Redo() 1287*cdf0e10cSrcweir { 1288*cdf0e10cSrcweir BeginRedo(); 1289*cdf0e10cSrcweir 1290*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1291*cdf0e10cSrcweir ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP ); 1292*cdf0e10cSrcweir 1293*cdf0e10cSrcweir EnableDrawAdjust( pDoc, sal_False ); //! include in ScBlockUndo? 1294*cdf0e10cSrcweir 1295*cdf0e10cSrcweir // do not undo/redo objects and note captions, they are handled via drawing undo 1296*cdf0e10cSrcweir sal_uInt16 nRedoFlags = (IDF_ALL & ~IDF_OBJECTS) | IDF_NOCAPTIONS; 1297*cdf0e10cSrcweir 1298*cdf0e10cSrcweir /* TODO: Redoing note captions is quite tricky due to the fact that a 1299*cdf0e10cSrcweir helper clip document is used. While (re-)pasting the contents to the 1300*cdf0e10cSrcweir destination area, the original pointers to the captions created while 1301*cdf0e10cSrcweir dropping have to be restored. A simple CopyFromClip() would create new 1302*cdf0e10cSrcweir caption objects that are not tracked by drawing undo, and the captions 1303*cdf0e10cSrcweir restored by drawing redo would live without cell note objects pointing 1304*cdf0e10cSrcweir to them. So, first, CopyToClip() and CopyFromClip() are called without 1305*cdf0e10cSrcweir cloning the caption objects. This leads to cell notes pointing to the 1306*cdf0e10cSrcweir wrong captions from source area that will be removed by drawing redo 1307*cdf0e10cSrcweir later. Second, the pointers to the new captions have to be restored. 1308*cdf0e10cSrcweir Sadly, currently these pointers are not stored anywhere but in the list 1309*cdf0e10cSrcweir of drawing undo actions. */ 1310*cdf0e10cSrcweir 1311*cdf0e10cSrcweir SCTAB nTab; 1312*cdf0e10cSrcweir ScMarkData aSourceMark; 1313*cdf0e10cSrcweir for (nTab=aSrcRange.aStart.Tab(); nTab<=aSrcRange.aEnd.Tab(); nTab++) 1314*cdf0e10cSrcweir aSourceMark.SelectTable( nTab, sal_True ); 1315*cdf0e10cSrcweir 1316*cdf0e10cSrcweir // do not clone objects and note captions into clipdoc (see above) 1317*cdf0e10cSrcweir ScClipParam aClipParam(aSrcRange, bCut); 1318*cdf0e10cSrcweir pDoc->CopyToClip(aClipParam, pClipDoc, &aSourceMark, false, bKeepScenarioFlags, false, false); 1319*cdf0e10cSrcweir 1320*cdf0e10cSrcweir if (bCut) 1321*cdf0e10cSrcweir { 1322*cdf0e10cSrcweir ScRange aSrcPaintRange = aSrcRange; 1323*cdf0e10cSrcweir pDoc->ExtendMerge( aSrcPaintRange ); // before deleting 1324*cdf0e10cSrcweir sal_uInt16 nExtFlags = 0; 1325*cdf0e10cSrcweir pDocShell->UpdatePaintExt( nExtFlags, aSrcPaintRange ); 1326*cdf0e10cSrcweir pDoc->DeleteAreaTab( aSrcRange, nRedoFlags ); 1327*cdf0e10cSrcweir PaintArea( aSrcPaintRange, nExtFlags ); 1328*cdf0e10cSrcweir } 1329*cdf0e10cSrcweir 1330*cdf0e10cSrcweir ScMarkData aDestMark; 1331*cdf0e10cSrcweir for (nTab=aDestRange.aStart.Tab(); nTab<=aDestRange.aEnd.Tab(); nTab++) 1332*cdf0e10cSrcweir aDestMark.SelectTable( nTab, sal_True ); 1333*cdf0e10cSrcweir 1334*cdf0e10cSrcweir sal_Bool bIncludeFiltered = bCut; 1335*cdf0e10cSrcweir // TODO: restore old note captions instead of cloning new captions... 1336*cdf0e10cSrcweir pDoc->CopyFromClip( aDestRange, aDestMark, IDF_ALL & ~IDF_OBJECTS, NULL, pClipDoc, sal_True, sal_False, bIncludeFiltered ); 1337*cdf0e10cSrcweir 1338*cdf0e10cSrcweir if (bCut) 1339*cdf0e10cSrcweir for (nTab=aSrcRange.aStart.Tab(); nTab<=aSrcRange.aEnd.Tab(); nTab++) 1340*cdf0e10cSrcweir pDoc->RefreshAutoFilter( aSrcRange.aStart.Col(), aSrcRange.aStart.Row(), 1341*cdf0e10cSrcweir aSrcRange.aEnd.Col(), aSrcRange.aEnd.Row(), nTab ); 1342*cdf0e10cSrcweir 1343*cdf0e10cSrcweir // skipped rows and merged cells don't mix 1344*cdf0e10cSrcweir if ( !bIncludeFiltered && pClipDoc->HasClipFilteredRows() ) 1345*cdf0e10cSrcweir pDocShell->GetDocFunc().UnmergeCells( aDestRange, sal_False, sal_True ); 1346*cdf0e10cSrcweir 1347*cdf0e10cSrcweir for (nTab=aDestRange.aStart.Tab(); nTab<=aDestRange.aEnd.Tab(); nTab++) 1348*cdf0e10cSrcweir { 1349*cdf0e10cSrcweir SCCOL nEndCol = aDestRange.aEnd.Col(); 1350*cdf0e10cSrcweir SCROW nEndRow = aDestRange.aEnd.Row(); 1351*cdf0e10cSrcweir pDoc->ExtendMerge( aDestRange.aStart.Col(), aDestRange.aStart.Row(), 1352*cdf0e10cSrcweir nEndCol, nEndRow, nTab, sal_True ); 1353*cdf0e10cSrcweir PaintArea( ScRange( aDestRange.aStart.Col(), aDestRange.aStart.Row(), nTab, 1354*cdf0e10cSrcweir nEndCol, nEndRow, nTab ), 0 ); 1355*cdf0e10cSrcweir } 1356*cdf0e10cSrcweir 1357*cdf0e10cSrcweir SetChangeTrack(); 1358*cdf0e10cSrcweir 1359*cdf0e10cSrcweir delete pClipDoc; 1360*cdf0e10cSrcweir ShowTable( aDestRange.aStart.Tab() ); 1361*cdf0e10cSrcweir 1362*cdf0e10cSrcweir RedoSdrUndoAction( pDrawUndo ); //! include in ScBlockUndo? 1363*cdf0e10cSrcweir EnableDrawAdjust( pDoc, sal_True ); //! include in ScBlockUndo? 1364*cdf0e10cSrcweir 1365*cdf0e10cSrcweir EndRedo(); 1366*cdf0e10cSrcweir SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); 1367*cdf0e10cSrcweir } 1368*cdf0e10cSrcweir 1369*cdf0e10cSrcweir void __EXPORT ScUndoDragDrop::Repeat(SfxRepeatTarget& /* rTarget */) 1370*cdf0e10cSrcweir { 1371*cdf0e10cSrcweir } 1372*cdf0e10cSrcweir 1373*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoDragDrop::CanRepeat(SfxRepeatTarget& /* rTarget */) const 1374*cdf0e10cSrcweir { 1375*cdf0e10cSrcweir return sal_False; // geht nicht 1376*cdf0e10cSrcweir } 1377*cdf0e10cSrcweir 1378*cdf0e10cSrcweir 1379*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1380*cdf0e10cSrcweir // 1381*cdf0e10cSrcweir // Liste der Bereichsnamen einfuegen 1382*cdf0e10cSrcweir // (Einfuegen|Name|Einfuegen =>[Liste]) 1383*cdf0e10cSrcweir // 1384*cdf0e10cSrcweir 1385*cdf0e10cSrcweir ScUndoListNames::ScUndoListNames( ScDocShell* pNewDocShell, const ScRange& rRange, 1386*cdf0e10cSrcweir ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc ) : 1387*cdf0e10cSrcweir ScBlockUndo( pNewDocShell, rRange, SC_UNDO_AUTOHEIGHT ), 1388*cdf0e10cSrcweir pUndoDoc( pNewUndoDoc ), 1389*cdf0e10cSrcweir pRedoDoc( pNewRedoDoc ) 1390*cdf0e10cSrcweir { 1391*cdf0e10cSrcweir } 1392*cdf0e10cSrcweir 1393*cdf0e10cSrcweir __EXPORT ScUndoListNames::~ScUndoListNames() 1394*cdf0e10cSrcweir { 1395*cdf0e10cSrcweir delete pUndoDoc; 1396*cdf0e10cSrcweir delete pRedoDoc; 1397*cdf0e10cSrcweir } 1398*cdf0e10cSrcweir 1399*cdf0e10cSrcweir String __EXPORT ScUndoListNames::GetComment() const 1400*cdf0e10cSrcweir { 1401*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_LISTNAMES ); 1402*cdf0e10cSrcweir } 1403*cdf0e10cSrcweir 1404*cdf0e10cSrcweir void ScUndoListNames::DoChange( ScDocument* pSrcDoc ) const 1405*cdf0e10cSrcweir { 1406*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1407*cdf0e10cSrcweir 1408*cdf0e10cSrcweir pDoc->DeleteAreaTab( aBlockRange, IDF_ALL ); 1409*cdf0e10cSrcweir pSrcDoc->CopyToDocument( aBlockRange, IDF_ALL, sal_False, pDoc ); 1410*cdf0e10cSrcweir pDocShell->PostPaint( aBlockRange, PAINT_GRID ); 1411*cdf0e10cSrcweir pDocShell->PostDataChanged(); 1412*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 1413*cdf0e10cSrcweir if (pViewShell) 1414*cdf0e10cSrcweir pViewShell->CellContentChanged(); 1415*cdf0e10cSrcweir } 1416*cdf0e10cSrcweir 1417*cdf0e10cSrcweir void __EXPORT ScUndoListNames::Undo() 1418*cdf0e10cSrcweir { 1419*cdf0e10cSrcweir BeginUndo(); 1420*cdf0e10cSrcweir DoChange(pUndoDoc); 1421*cdf0e10cSrcweir EndUndo(); 1422*cdf0e10cSrcweir } 1423*cdf0e10cSrcweir 1424*cdf0e10cSrcweir void __EXPORT ScUndoListNames::Redo() 1425*cdf0e10cSrcweir { 1426*cdf0e10cSrcweir BeginRedo(); 1427*cdf0e10cSrcweir DoChange(pRedoDoc); 1428*cdf0e10cSrcweir EndRedo(); 1429*cdf0e10cSrcweir } 1430*cdf0e10cSrcweir 1431*cdf0e10cSrcweir void __EXPORT ScUndoListNames::Repeat(SfxRepeatTarget& rTarget) 1432*cdf0e10cSrcweir { 1433*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 1434*cdf0e10cSrcweir ((ScTabViewTarget&)rTarget).GetViewShell()->InsertNameList(); 1435*cdf0e10cSrcweir } 1436*cdf0e10cSrcweir 1437*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoListNames::CanRepeat(SfxRepeatTarget& rTarget) const 1438*cdf0e10cSrcweir { 1439*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 1440*cdf0e10cSrcweir } 1441*cdf0e10cSrcweir 1442*cdf0e10cSrcweir 1443*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1444*cdf0e10cSrcweir // 1445*cdf0e10cSrcweir // Szenario anwenden 1446*cdf0e10cSrcweir // (Extras|Szenarien) 1447*cdf0e10cSrcweir // 1448*cdf0e10cSrcweir 1449*cdf0e10cSrcweir ScUndoUseScenario::ScUndoUseScenario( ScDocShell* pNewDocShell, 1450*cdf0e10cSrcweir const ScMarkData& rMark, 1451*cdf0e10cSrcweir /*C*/ const ScArea& rDestArea, 1452*cdf0e10cSrcweir ScDocument* pNewUndoDoc, 1453*cdf0e10cSrcweir const String& rNewName ) : 1454*cdf0e10cSrcweir ScSimpleUndo( pNewDocShell ), 1455*cdf0e10cSrcweir pUndoDoc( pNewUndoDoc ), 1456*cdf0e10cSrcweir aMarkData( rMark ), 1457*cdf0e10cSrcweir aName( rNewName ) 1458*cdf0e10cSrcweir { 1459*cdf0e10cSrcweir aRange.aStart.SetCol(rDestArea.nColStart); 1460*cdf0e10cSrcweir aRange.aStart.SetRow(rDestArea.nRowStart); 1461*cdf0e10cSrcweir aRange.aStart.SetTab(rDestArea.nTab); 1462*cdf0e10cSrcweir aRange.aEnd.SetCol(rDestArea.nColEnd); 1463*cdf0e10cSrcweir aRange.aEnd.SetRow(rDestArea.nRowEnd); 1464*cdf0e10cSrcweir aRange.aEnd.SetTab(rDestArea.nTab); 1465*cdf0e10cSrcweir } 1466*cdf0e10cSrcweir 1467*cdf0e10cSrcweir __EXPORT ScUndoUseScenario::~ScUndoUseScenario() 1468*cdf0e10cSrcweir { 1469*cdf0e10cSrcweir delete pUndoDoc; 1470*cdf0e10cSrcweir } 1471*cdf0e10cSrcweir 1472*cdf0e10cSrcweir String __EXPORT ScUndoUseScenario::GetComment() const 1473*cdf0e10cSrcweir { 1474*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_USESCENARIO ); 1475*cdf0e10cSrcweir } 1476*cdf0e10cSrcweir 1477*cdf0e10cSrcweir void __EXPORT ScUndoUseScenario::Undo() 1478*cdf0e10cSrcweir { 1479*cdf0e10cSrcweir BeginUndo(); 1480*cdf0e10cSrcweir 1481*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 1482*cdf0e10cSrcweir if (pViewShell) 1483*cdf0e10cSrcweir { 1484*cdf0e10cSrcweir pViewShell->DoneBlockMode(); 1485*cdf0e10cSrcweir pViewShell->InitOwnBlockMode(); 1486*cdf0e10cSrcweir } 1487*cdf0e10cSrcweir 1488*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1489*cdf0e10cSrcweir pDoc->DeleteSelection( IDF_ALL, aMarkData ); 1490*cdf0e10cSrcweir pUndoDoc->CopyToDocument( aRange, IDF_ALL, sal_True, pDoc, &aMarkData ); 1491*cdf0e10cSrcweir 1492*cdf0e10cSrcweir // Szenario-Tabellen 1493*cdf0e10cSrcweir sal_Bool bFrame = sal_False; 1494*cdf0e10cSrcweir SCTAB nTab = aRange.aStart.Tab(); 1495*cdf0e10cSrcweir SCTAB nEndTab = nTab; 1496*cdf0e10cSrcweir while ( pUndoDoc->HasTable(nEndTab+1) && pUndoDoc->IsScenario(nEndTab+1) ) 1497*cdf0e10cSrcweir ++nEndTab; 1498*cdf0e10cSrcweir for (SCTAB i = nTab+1; i<=nEndTab; i++) 1499*cdf0e10cSrcweir { 1500*cdf0e10cSrcweir // Flags immer 1501*cdf0e10cSrcweir String aComment; 1502*cdf0e10cSrcweir Color aColor; 1503*cdf0e10cSrcweir sal_uInt16 nScenFlags; 1504*cdf0e10cSrcweir pUndoDoc->GetScenarioData( i, aComment, aColor, nScenFlags ); 1505*cdf0e10cSrcweir pDoc->SetScenarioData( i, aComment, aColor, nScenFlags ); 1506*cdf0e10cSrcweir sal_Bool bActive = pUndoDoc->IsActiveScenario( i ); 1507*cdf0e10cSrcweir pDoc->SetActiveScenario( i, bActive ); 1508*cdf0e10cSrcweir // Bei Zurueckkopier-Szenarios auch Inhalte 1509*cdf0e10cSrcweir if ( nScenFlags & SC_SCENARIO_TWOWAY ) 1510*cdf0e10cSrcweir { 1511*cdf0e10cSrcweir pDoc->DeleteAreaTab( 0,0, MAXCOL,MAXROW, i, IDF_ALL ); 1512*cdf0e10cSrcweir pUndoDoc->CopyToDocument( 0,0,i, MAXCOL,MAXROW,i, IDF_ALL,sal_False, pDoc ); 1513*cdf0e10cSrcweir } 1514*cdf0e10cSrcweir if ( nScenFlags & SC_SCENARIO_SHOWFRAME ) 1515*cdf0e10cSrcweir bFrame = sal_True; 1516*cdf0e10cSrcweir } 1517*cdf0e10cSrcweir 1518*cdf0e10cSrcweir // Wenn sichtbare Rahmen, dann alles painten 1519*cdf0e10cSrcweir if (bFrame) 1520*cdf0e10cSrcweir pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_EXTRAS ); 1521*cdf0e10cSrcweir else 1522*cdf0e10cSrcweir pDocShell->PostPaint( aRange, PAINT_GRID | PAINT_EXTRAS ); 1523*cdf0e10cSrcweir pDocShell->PostDataChanged(); 1524*cdf0e10cSrcweir if (pViewShell) 1525*cdf0e10cSrcweir pViewShell->CellContentChanged(); 1526*cdf0e10cSrcweir 1527*cdf0e10cSrcweir ShowTable( aRange.aStart.Tab() ); 1528*cdf0e10cSrcweir 1529*cdf0e10cSrcweir EndUndo(); 1530*cdf0e10cSrcweir } 1531*cdf0e10cSrcweir 1532*cdf0e10cSrcweir void __EXPORT ScUndoUseScenario::Redo() 1533*cdf0e10cSrcweir { 1534*cdf0e10cSrcweir SCTAB nTab = aRange.aStart.Tab(); 1535*cdf0e10cSrcweir BeginRedo(); 1536*cdf0e10cSrcweir 1537*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 1538*cdf0e10cSrcweir if (pViewShell) 1539*cdf0e10cSrcweir { 1540*cdf0e10cSrcweir pViewShell->SetTabNo( nTab ); 1541*cdf0e10cSrcweir pViewShell->DoneBlockMode(); 1542*cdf0e10cSrcweir pViewShell->InitOwnBlockMode(); 1543*cdf0e10cSrcweir } 1544*cdf0e10cSrcweir 1545*cdf0e10cSrcweir pDocShell->UseScenario( nTab, aName, sal_False ); 1546*cdf0e10cSrcweir 1547*cdf0e10cSrcweir EndRedo(); 1548*cdf0e10cSrcweir } 1549*cdf0e10cSrcweir 1550*cdf0e10cSrcweir void __EXPORT ScUndoUseScenario::Repeat(SfxRepeatTarget& rTarget) 1551*cdf0e10cSrcweir { 1552*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 1553*cdf0e10cSrcweir { 1554*cdf0e10cSrcweir String aTemp = aName; 1555*cdf0e10cSrcweir ((ScTabViewTarget&)rTarget).GetViewShell()->UseScenario(aTemp); 1556*cdf0e10cSrcweir } 1557*cdf0e10cSrcweir } 1558*cdf0e10cSrcweir 1559*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoUseScenario::CanRepeat(SfxRepeatTarget& rTarget) const 1560*cdf0e10cSrcweir { 1561*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 1562*cdf0e10cSrcweir { 1563*cdf0e10cSrcweir ScViewData* pViewData = ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData(); 1564*cdf0e10cSrcweir return !pViewData->GetDocument()->IsScenario( pViewData->GetTabNo() ); 1565*cdf0e10cSrcweir } 1566*cdf0e10cSrcweir return sal_False; 1567*cdf0e10cSrcweir } 1568*cdf0e10cSrcweir 1569*cdf0e10cSrcweir 1570*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1571*cdf0e10cSrcweir // 1572*cdf0e10cSrcweir // Vorlage anwenden 1573*cdf0e10cSrcweir // (Format|Vorlagenkatalog) 1574*cdf0e10cSrcweir // 1575*cdf0e10cSrcweir 1576*cdf0e10cSrcweir ScUndoSelectionStyle::ScUndoSelectionStyle( ScDocShell* pNewDocShell, 1577*cdf0e10cSrcweir const ScMarkData& rMark, 1578*cdf0e10cSrcweir const ScRange& rRange, 1579*cdf0e10cSrcweir const String& rName, 1580*cdf0e10cSrcweir ScDocument* pNewUndoDoc ) : 1581*cdf0e10cSrcweir ScSimpleUndo( pNewDocShell ), 1582*cdf0e10cSrcweir aMarkData( rMark ), 1583*cdf0e10cSrcweir pUndoDoc( pNewUndoDoc ), 1584*cdf0e10cSrcweir aStyleName( rName ), 1585*cdf0e10cSrcweir aRange( rRange ) 1586*cdf0e10cSrcweir { 1587*cdf0e10cSrcweir aMarkData.MarkToMulti(); 1588*cdf0e10cSrcweir } 1589*cdf0e10cSrcweir 1590*cdf0e10cSrcweir __EXPORT ScUndoSelectionStyle::~ScUndoSelectionStyle() 1591*cdf0e10cSrcweir { 1592*cdf0e10cSrcweir delete pUndoDoc; 1593*cdf0e10cSrcweir } 1594*cdf0e10cSrcweir 1595*cdf0e10cSrcweir String __EXPORT ScUndoSelectionStyle::GetComment() const 1596*cdf0e10cSrcweir { 1597*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_APPLYCELLSTYLE ); 1598*cdf0e10cSrcweir } 1599*cdf0e10cSrcweir 1600*cdf0e10cSrcweir void ScUndoSelectionStyle::DoChange( const sal_Bool bUndo ) 1601*cdf0e10cSrcweir { 1602*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1603*cdf0e10cSrcweir 1604*cdf0e10cSrcweir SetViewMarkData( aMarkData ); 1605*cdf0e10cSrcweir 1606*cdf0e10cSrcweir ScRange aWorkRange( aRange ); 1607*cdf0e10cSrcweir if ( pDoc->HasAttrib( aWorkRange, HASATTR_MERGED ) ) // zusammengefasste Zellen? 1608*cdf0e10cSrcweir pDoc->ExtendMerge( aWorkRange, sal_True ); 1609*cdf0e10cSrcweir 1610*cdf0e10cSrcweir sal_uInt16 nExtFlags = 0; 1611*cdf0e10cSrcweir pDocShell->UpdatePaintExt( nExtFlags, aWorkRange ); 1612*cdf0e10cSrcweir 1613*cdf0e10cSrcweir if (bUndo) // bei Undo alte Daten wieder reinschubsen 1614*cdf0e10cSrcweir { 1615*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 1616*cdf0e10cSrcweir ScRange aCopyRange = aWorkRange; 1617*cdf0e10cSrcweir aCopyRange.aStart.SetTab(0); 1618*cdf0e10cSrcweir aCopyRange.aEnd.SetTab(nTabCount-1); 1619*cdf0e10cSrcweir pUndoDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, sal_True, pDoc, &aMarkData ); 1620*cdf0e10cSrcweir } 1621*cdf0e10cSrcweir else // bei Redo Style wieder zuweisen 1622*cdf0e10cSrcweir { 1623*cdf0e10cSrcweir ScStyleSheetPool* pStlPool = pDoc->GetStyleSheetPool(); 1624*cdf0e10cSrcweir ScStyleSheet* pStyleSheet = 1625*cdf0e10cSrcweir (ScStyleSheet*) pStlPool->Find( aStyleName, SFX_STYLE_FAMILY_PARA ); 1626*cdf0e10cSrcweir if (!pStyleSheet) 1627*cdf0e10cSrcweir { 1628*cdf0e10cSrcweir DBG_ERROR("StyleSheet not found"); 1629*cdf0e10cSrcweir return; 1630*cdf0e10cSrcweir } 1631*cdf0e10cSrcweir pDoc->ApplySelectionStyle( *pStyleSheet, aMarkData ); 1632*cdf0e10cSrcweir } 1633*cdf0e10cSrcweir 1634*cdf0e10cSrcweir pDocShell->UpdatePaintExt( nExtFlags, aWorkRange ); 1635*cdf0e10cSrcweir 1636*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 1637*cdf0e10cSrcweir if ( !( (pViewShell) && pViewShell->AdjustBlockHeight() ) ) 1638*cdf0e10cSrcweir /*A*/ pDocShell->PostPaint( aWorkRange, PAINT_GRID | PAINT_EXTRAS, nExtFlags ); 1639*cdf0e10cSrcweir 1640*cdf0e10cSrcweir ShowTable( aWorkRange.aStart.Tab() ); 1641*cdf0e10cSrcweir } 1642*cdf0e10cSrcweir 1643*cdf0e10cSrcweir void __EXPORT ScUndoSelectionStyle::Undo() 1644*cdf0e10cSrcweir { 1645*cdf0e10cSrcweir BeginUndo(); 1646*cdf0e10cSrcweir DoChange( sal_True ); 1647*cdf0e10cSrcweir EndUndo(); 1648*cdf0e10cSrcweir } 1649*cdf0e10cSrcweir 1650*cdf0e10cSrcweir void __EXPORT ScUndoSelectionStyle::Redo() 1651*cdf0e10cSrcweir { 1652*cdf0e10cSrcweir BeginRedo(); 1653*cdf0e10cSrcweir DoChange( sal_False ); 1654*cdf0e10cSrcweir EndRedo(); 1655*cdf0e10cSrcweir } 1656*cdf0e10cSrcweir 1657*cdf0e10cSrcweir void __EXPORT ScUndoSelectionStyle::Repeat(SfxRepeatTarget& rTarget) 1658*cdf0e10cSrcweir { 1659*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 1660*cdf0e10cSrcweir { 1661*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1662*cdf0e10cSrcweir ScStyleSheetPool* pStlPool = pDoc->GetStyleSheetPool(); 1663*cdf0e10cSrcweir ScStyleSheet* pStyleSheet = (ScStyleSheet*) pStlPool-> 1664*cdf0e10cSrcweir Find( aStyleName, SFX_STYLE_FAMILY_PARA ); 1665*cdf0e10cSrcweir if (!pStyleSheet) 1666*cdf0e10cSrcweir { 1667*cdf0e10cSrcweir DBG_ERROR("StyleSheet not found"); 1668*cdf0e10cSrcweir return; 1669*cdf0e10cSrcweir } 1670*cdf0e10cSrcweir 1671*cdf0e10cSrcweir ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell(); 1672*cdf0e10cSrcweir rViewShell.SetStyleSheetToMarked( pStyleSheet, sal_True ); 1673*cdf0e10cSrcweir } 1674*cdf0e10cSrcweir } 1675*cdf0e10cSrcweir 1676*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoSelectionStyle::CanRepeat(SfxRepeatTarget& rTarget) const 1677*cdf0e10cSrcweir { 1678*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 1679*cdf0e10cSrcweir } 1680*cdf0e10cSrcweir 1681*cdf0e10cSrcweir sal_uInt16 __EXPORT ScUndoSelectionStyle::GetId() const 1682*cdf0e10cSrcweir { 1683*cdf0e10cSrcweir return STR_UNDO_APPLYCELLSTYLE; 1684*cdf0e10cSrcweir } 1685*cdf0e10cSrcweir 1686*cdf0e10cSrcweir 1687*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1688*cdf0e10cSrcweir // 1689*cdf0e10cSrcweir // Matrix-Formel eingeben 1690*cdf0e10cSrcweir // 1691*cdf0e10cSrcweir 1692*cdf0e10cSrcweir ScUndoEnterMatrix::ScUndoEnterMatrix( ScDocShell* pNewDocShell, const ScRange& rArea, 1693*cdf0e10cSrcweir ScDocument* pNewUndoDoc, const String& rForm ) : 1694*cdf0e10cSrcweir ScBlockUndo( pNewDocShell, rArea, SC_UNDO_SIMPLE ), 1695*cdf0e10cSrcweir pUndoDoc( pNewUndoDoc ), 1696*cdf0e10cSrcweir aFormula( rForm ) 1697*cdf0e10cSrcweir { 1698*cdf0e10cSrcweir SetChangeTrack(); 1699*cdf0e10cSrcweir } 1700*cdf0e10cSrcweir 1701*cdf0e10cSrcweir __EXPORT ScUndoEnterMatrix::~ScUndoEnterMatrix() 1702*cdf0e10cSrcweir { 1703*cdf0e10cSrcweir delete pUndoDoc; 1704*cdf0e10cSrcweir } 1705*cdf0e10cSrcweir 1706*cdf0e10cSrcweir String __EXPORT ScUndoEnterMatrix::GetComment() const 1707*cdf0e10cSrcweir { 1708*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_ENTERMATRIX ); 1709*cdf0e10cSrcweir } 1710*cdf0e10cSrcweir 1711*cdf0e10cSrcweir void ScUndoEnterMatrix::SetChangeTrack() 1712*cdf0e10cSrcweir { 1713*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1714*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); 1715*cdf0e10cSrcweir if ( pChangeTrack ) 1716*cdf0e10cSrcweir pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc, 1717*cdf0e10cSrcweir nStartChangeAction, nEndChangeAction ); 1718*cdf0e10cSrcweir else 1719*cdf0e10cSrcweir nStartChangeAction = nEndChangeAction = 0; 1720*cdf0e10cSrcweir } 1721*cdf0e10cSrcweir 1722*cdf0e10cSrcweir void __EXPORT ScUndoEnterMatrix::Undo() 1723*cdf0e10cSrcweir { 1724*cdf0e10cSrcweir BeginUndo(); 1725*cdf0e10cSrcweir 1726*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1727*cdf0e10cSrcweir 1728*cdf0e10cSrcweir pDoc->DeleteAreaTab( aBlockRange, IDF_ALL & ~IDF_NOTE ); 1729*cdf0e10cSrcweir pUndoDoc->CopyToDocument( aBlockRange, IDF_ALL & ~IDF_NOTE, sal_False, pDoc ); 1730*cdf0e10cSrcweir pDocShell->PostPaint( aBlockRange, PAINT_GRID ); 1731*cdf0e10cSrcweir pDocShell->PostDataChanged(); 1732*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 1733*cdf0e10cSrcweir if (pViewShell) 1734*cdf0e10cSrcweir pViewShell->CellContentChanged(); 1735*cdf0e10cSrcweir 1736*cdf0e10cSrcweir ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack(); 1737*cdf0e10cSrcweir if ( pChangeTrack ) 1738*cdf0e10cSrcweir pChangeTrack->Undo( nStartChangeAction, nEndChangeAction ); 1739*cdf0e10cSrcweir 1740*cdf0e10cSrcweir EndUndo(); 1741*cdf0e10cSrcweir } 1742*cdf0e10cSrcweir 1743*cdf0e10cSrcweir void __EXPORT ScUndoEnterMatrix::Redo() 1744*cdf0e10cSrcweir { 1745*cdf0e10cSrcweir BeginRedo(); 1746*cdf0e10cSrcweir 1747*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1748*cdf0e10cSrcweir 1749*cdf0e10cSrcweir ScMarkData aDestMark; 1750*cdf0e10cSrcweir aDestMark.SelectOneTable( aBlockRange.aStart.Tab() ); 1751*cdf0e10cSrcweir aDestMark.SetMarkArea( aBlockRange ); 1752*cdf0e10cSrcweir 1753*cdf0e10cSrcweir pDoc->InsertMatrixFormula( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(), 1754*cdf0e10cSrcweir aBlockRange.aEnd.Col(), aBlockRange.aEnd.Row(), 1755*cdf0e10cSrcweir aDestMark, aFormula ); 1756*cdf0e10cSrcweir // pDocShell->PostPaint( aBlockRange, PAINT_GRID ); // nicht noetig ??? 1757*cdf0e10cSrcweir 1758*cdf0e10cSrcweir SetChangeTrack(); 1759*cdf0e10cSrcweir 1760*cdf0e10cSrcweir EndRedo(); 1761*cdf0e10cSrcweir } 1762*cdf0e10cSrcweir 1763*cdf0e10cSrcweir void __EXPORT ScUndoEnterMatrix::Repeat(SfxRepeatTarget& rTarget) 1764*cdf0e10cSrcweir { 1765*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 1766*cdf0e10cSrcweir { 1767*cdf0e10cSrcweir String aTemp = aFormula; 1768*cdf0e10cSrcweir ((ScTabViewTarget&)rTarget).GetViewShell()->EnterMatrix(aTemp); 1769*cdf0e10cSrcweir } 1770*cdf0e10cSrcweir } 1771*cdf0e10cSrcweir 1772*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoEnterMatrix::CanRepeat(SfxRepeatTarget& rTarget) const 1773*cdf0e10cSrcweir { 1774*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 1775*cdf0e10cSrcweir } 1776*cdf0e10cSrcweir 1777*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1778*cdf0e10cSrcweir // 1779*cdf0e10cSrcweir // Einzug vermindern / erhoehen 1780*cdf0e10cSrcweir // 1781*cdf0e10cSrcweir 1782*cdf0e10cSrcweir ScRange lcl_GetMultiMarkRange( const ScMarkData& rMark ) 1783*cdf0e10cSrcweir { 1784*cdf0e10cSrcweir DBG_ASSERT( rMark.IsMultiMarked(), "wrong mark type" ); 1785*cdf0e10cSrcweir 1786*cdf0e10cSrcweir ScRange aRange; 1787*cdf0e10cSrcweir rMark.GetMultiMarkArea( aRange ); 1788*cdf0e10cSrcweir return aRange; 1789*cdf0e10cSrcweir } 1790*cdf0e10cSrcweir 1791*cdf0e10cSrcweir ScUndoIndent::ScUndoIndent( ScDocShell* pNewDocShell, const ScMarkData& rMark, 1792*cdf0e10cSrcweir ScDocument* pNewUndoDoc, sal_Bool bIncrement ) : 1793*cdf0e10cSrcweir ScBlockUndo( pNewDocShell, lcl_GetMultiMarkRange(rMark), SC_UNDO_AUTOHEIGHT ), 1794*cdf0e10cSrcweir aMarkData( rMark ), 1795*cdf0e10cSrcweir pUndoDoc( pNewUndoDoc ), 1796*cdf0e10cSrcweir bIsIncrement( bIncrement ) 1797*cdf0e10cSrcweir { 1798*cdf0e10cSrcweir } 1799*cdf0e10cSrcweir 1800*cdf0e10cSrcweir __EXPORT ScUndoIndent::~ScUndoIndent() 1801*cdf0e10cSrcweir { 1802*cdf0e10cSrcweir delete pUndoDoc; 1803*cdf0e10cSrcweir } 1804*cdf0e10cSrcweir 1805*cdf0e10cSrcweir String __EXPORT ScUndoIndent::GetComment() const 1806*cdf0e10cSrcweir { 1807*cdf0e10cSrcweir sal_uInt16 nId = bIsIncrement ? STR_UNDO_INC_INDENT : STR_UNDO_DEC_INDENT; 1808*cdf0e10cSrcweir return ScGlobal::GetRscString( nId ); 1809*cdf0e10cSrcweir } 1810*cdf0e10cSrcweir 1811*cdf0e10cSrcweir void __EXPORT ScUndoIndent::Undo() 1812*cdf0e10cSrcweir { 1813*cdf0e10cSrcweir BeginUndo(); 1814*cdf0e10cSrcweir 1815*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1816*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 1817*cdf0e10cSrcweir ScRange aCopyRange = aBlockRange; 1818*cdf0e10cSrcweir aCopyRange.aStart.SetTab(0); 1819*cdf0e10cSrcweir aCopyRange.aEnd.SetTab(nTabCount-1); 1820*cdf0e10cSrcweir pUndoDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, sal_True, pDoc, &aMarkData ); 1821*cdf0e10cSrcweir pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); 1822*cdf0e10cSrcweir 1823*cdf0e10cSrcweir EndUndo(); 1824*cdf0e10cSrcweir } 1825*cdf0e10cSrcweir 1826*cdf0e10cSrcweir void __EXPORT ScUndoIndent::Redo() 1827*cdf0e10cSrcweir { 1828*cdf0e10cSrcweir BeginRedo(); 1829*cdf0e10cSrcweir 1830*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1831*cdf0e10cSrcweir pDoc->ChangeSelectionIndent( bIsIncrement, aMarkData ); 1832*cdf0e10cSrcweir pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); 1833*cdf0e10cSrcweir 1834*cdf0e10cSrcweir EndRedo(); 1835*cdf0e10cSrcweir } 1836*cdf0e10cSrcweir 1837*cdf0e10cSrcweir void __EXPORT ScUndoIndent::Repeat(SfxRepeatTarget& rTarget) 1838*cdf0e10cSrcweir { 1839*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 1840*cdf0e10cSrcweir ((ScTabViewTarget&)rTarget).GetViewShell()->ChangeIndent( bIsIncrement ); 1841*cdf0e10cSrcweir } 1842*cdf0e10cSrcweir 1843*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoIndent::CanRepeat(SfxRepeatTarget& rTarget) const 1844*cdf0e10cSrcweir { 1845*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 1846*cdf0e10cSrcweir } 1847*cdf0e10cSrcweir 1848*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1849*cdf0e10cSrcweir // 1850*cdf0e10cSrcweir // Transliteration for cells 1851*cdf0e10cSrcweir // 1852*cdf0e10cSrcweir 1853*cdf0e10cSrcweir ScUndoTransliterate::ScUndoTransliterate( ScDocShell* pNewDocShell, const ScMarkData& rMark, 1854*cdf0e10cSrcweir ScDocument* pNewUndoDoc, sal_Int32 nType ) : 1855*cdf0e10cSrcweir ScBlockUndo( pNewDocShell, lcl_GetMultiMarkRange(rMark), SC_UNDO_AUTOHEIGHT ), 1856*cdf0e10cSrcweir aMarkData( rMark ), 1857*cdf0e10cSrcweir pUndoDoc( pNewUndoDoc ), 1858*cdf0e10cSrcweir nTransliterationType( nType ) 1859*cdf0e10cSrcweir { 1860*cdf0e10cSrcweir } 1861*cdf0e10cSrcweir 1862*cdf0e10cSrcweir __EXPORT ScUndoTransliterate::~ScUndoTransliterate() 1863*cdf0e10cSrcweir { 1864*cdf0e10cSrcweir delete pUndoDoc; 1865*cdf0e10cSrcweir } 1866*cdf0e10cSrcweir 1867*cdf0e10cSrcweir String __EXPORT ScUndoTransliterate::GetComment() const 1868*cdf0e10cSrcweir { 1869*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_TRANSLITERATE ); 1870*cdf0e10cSrcweir } 1871*cdf0e10cSrcweir 1872*cdf0e10cSrcweir void __EXPORT ScUndoTransliterate::Undo() 1873*cdf0e10cSrcweir { 1874*cdf0e10cSrcweir BeginUndo(); 1875*cdf0e10cSrcweir 1876*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1877*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 1878*cdf0e10cSrcweir ScRange aCopyRange = aBlockRange; 1879*cdf0e10cSrcweir aCopyRange.aStart.SetTab(0); 1880*cdf0e10cSrcweir aCopyRange.aEnd.SetTab(nTabCount-1); 1881*cdf0e10cSrcweir pUndoDoc->CopyToDocument( aCopyRange, IDF_CONTENTS, sal_True, pDoc, &aMarkData ); 1882*cdf0e10cSrcweir pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); 1883*cdf0e10cSrcweir 1884*cdf0e10cSrcweir EndUndo(); 1885*cdf0e10cSrcweir } 1886*cdf0e10cSrcweir 1887*cdf0e10cSrcweir void __EXPORT ScUndoTransliterate::Redo() 1888*cdf0e10cSrcweir { 1889*cdf0e10cSrcweir BeginRedo(); 1890*cdf0e10cSrcweir 1891*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1892*cdf0e10cSrcweir pDoc->TransliterateText( aMarkData, nTransliterationType ); 1893*cdf0e10cSrcweir pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); 1894*cdf0e10cSrcweir 1895*cdf0e10cSrcweir EndRedo(); 1896*cdf0e10cSrcweir } 1897*cdf0e10cSrcweir 1898*cdf0e10cSrcweir void __EXPORT ScUndoTransliterate::Repeat(SfxRepeatTarget& rTarget) 1899*cdf0e10cSrcweir { 1900*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 1901*cdf0e10cSrcweir ((ScTabViewTarget&)rTarget).GetViewShell()->TransliterateText( nTransliterationType ); 1902*cdf0e10cSrcweir } 1903*cdf0e10cSrcweir 1904*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoTransliterate::CanRepeat(SfxRepeatTarget& rTarget) const 1905*cdf0e10cSrcweir { 1906*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 1907*cdf0e10cSrcweir } 1908*cdf0e10cSrcweir 1909*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1910*cdf0e10cSrcweir // 1911*cdf0e10cSrcweir // einzelne Items per Which-IDs aus Bereich loeschen 1912*cdf0e10cSrcweir // 1913*cdf0e10cSrcweir 1914*cdf0e10cSrcweir ScUndoClearItems::ScUndoClearItems( ScDocShell* pNewDocShell, const ScMarkData& rMark, 1915*cdf0e10cSrcweir ScDocument* pNewUndoDoc, const sal_uInt16* pW ) : 1916*cdf0e10cSrcweir ScBlockUndo( pNewDocShell, lcl_GetMultiMarkRange(rMark), SC_UNDO_AUTOHEIGHT ), 1917*cdf0e10cSrcweir aMarkData( rMark ), 1918*cdf0e10cSrcweir pUndoDoc( pNewUndoDoc ), 1919*cdf0e10cSrcweir pWhich( NULL ) 1920*cdf0e10cSrcweir { 1921*cdf0e10cSrcweir DBG_ASSERT( pW, "ScUndoClearItems: Which-Pointer ist 0" ); 1922*cdf0e10cSrcweir 1923*cdf0e10cSrcweir sal_uInt16 nCount = 0; 1924*cdf0e10cSrcweir while ( pW[nCount] ) 1925*cdf0e10cSrcweir ++nCount; 1926*cdf0e10cSrcweir pWhich = new sal_uInt16[nCount+1]; 1927*cdf0e10cSrcweir for (sal_uInt16 i=0; i<=nCount; i++) 1928*cdf0e10cSrcweir pWhich[i] = pW[i]; 1929*cdf0e10cSrcweir } 1930*cdf0e10cSrcweir 1931*cdf0e10cSrcweir __EXPORT ScUndoClearItems::~ScUndoClearItems() 1932*cdf0e10cSrcweir { 1933*cdf0e10cSrcweir delete pUndoDoc; 1934*cdf0e10cSrcweir delete pWhich; 1935*cdf0e10cSrcweir } 1936*cdf0e10cSrcweir 1937*cdf0e10cSrcweir String __EXPORT ScUndoClearItems::GetComment() const 1938*cdf0e10cSrcweir { 1939*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS ); 1940*cdf0e10cSrcweir } 1941*cdf0e10cSrcweir 1942*cdf0e10cSrcweir void __EXPORT ScUndoClearItems::Undo() 1943*cdf0e10cSrcweir { 1944*cdf0e10cSrcweir BeginUndo(); 1945*cdf0e10cSrcweir 1946*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1947*cdf0e10cSrcweir pUndoDoc->CopyToDocument( aBlockRange, IDF_ATTRIB, sal_True, pDoc, &aMarkData ); 1948*cdf0e10cSrcweir pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); 1949*cdf0e10cSrcweir 1950*cdf0e10cSrcweir EndUndo(); 1951*cdf0e10cSrcweir } 1952*cdf0e10cSrcweir 1953*cdf0e10cSrcweir void __EXPORT ScUndoClearItems::Redo() 1954*cdf0e10cSrcweir { 1955*cdf0e10cSrcweir BeginRedo(); 1956*cdf0e10cSrcweir 1957*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1958*cdf0e10cSrcweir pDoc->ClearSelectionItems( pWhich, aMarkData ); 1959*cdf0e10cSrcweir pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); 1960*cdf0e10cSrcweir 1961*cdf0e10cSrcweir EndRedo(); 1962*cdf0e10cSrcweir } 1963*cdf0e10cSrcweir 1964*cdf0e10cSrcweir void __EXPORT ScUndoClearItems::Repeat(SfxRepeatTarget& rTarget) 1965*cdf0e10cSrcweir { 1966*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 1967*cdf0e10cSrcweir { 1968*cdf0e10cSrcweir ScViewData* pViewData = ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData(); 1969*cdf0e10cSrcweir ScDocFunc aFunc(*pViewData->GetDocShell()); 1970*cdf0e10cSrcweir aFunc.ClearItems( pViewData->GetMarkData(), pWhich, sal_False ); 1971*cdf0e10cSrcweir } 1972*cdf0e10cSrcweir } 1973*cdf0e10cSrcweir 1974*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoClearItems::CanRepeat(SfxRepeatTarget& rTarget) const 1975*cdf0e10cSrcweir { 1976*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 1977*cdf0e10cSrcweir } 1978*cdf0e10cSrcweir 1979*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1980*cdf0e10cSrcweir // 1981*cdf0e10cSrcweir // Alle Umbrueche einer Tabelle loeschen 1982*cdf0e10cSrcweir // 1983*cdf0e10cSrcweir 1984*cdf0e10cSrcweir ScUndoRemoveBreaks::ScUndoRemoveBreaks( ScDocShell* pNewDocShell, 1985*cdf0e10cSrcweir SCTAB nNewTab, ScDocument* pNewUndoDoc ) : 1986*cdf0e10cSrcweir ScSimpleUndo( pNewDocShell ), 1987*cdf0e10cSrcweir nTab( nNewTab ), 1988*cdf0e10cSrcweir pUndoDoc( pNewUndoDoc ) 1989*cdf0e10cSrcweir { 1990*cdf0e10cSrcweir } 1991*cdf0e10cSrcweir 1992*cdf0e10cSrcweir __EXPORT ScUndoRemoveBreaks::~ScUndoRemoveBreaks() 1993*cdf0e10cSrcweir { 1994*cdf0e10cSrcweir delete pUndoDoc; 1995*cdf0e10cSrcweir } 1996*cdf0e10cSrcweir 1997*cdf0e10cSrcweir String __EXPORT ScUndoRemoveBreaks::GetComment() const 1998*cdf0e10cSrcweir { 1999*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_REMOVEBREAKS ); 2000*cdf0e10cSrcweir } 2001*cdf0e10cSrcweir 2002*cdf0e10cSrcweir void __EXPORT ScUndoRemoveBreaks::Undo() 2003*cdf0e10cSrcweir { 2004*cdf0e10cSrcweir BeginUndo(); 2005*cdf0e10cSrcweir 2006*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 2007*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 2008*cdf0e10cSrcweir 2009*cdf0e10cSrcweir pUndoDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, sal_False, pDoc ); 2010*cdf0e10cSrcweir if (pViewShell) 2011*cdf0e10cSrcweir pViewShell->UpdatePageBreakData( sal_True ); 2012*cdf0e10cSrcweir pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID ); 2013*cdf0e10cSrcweir 2014*cdf0e10cSrcweir EndUndo(); 2015*cdf0e10cSrcweir } 2016*cdf0e10cSrcweir 2017*cdf0e10cSrcweir void __EXPORT ScUndoRemoveBreaks::Redo() 2018*cdf0e10cSrcweir { 2019*cdf0e10cSrcweir BeginRedo(); 2020*cdf0e10cSrcweir 2021*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 2022*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 2023*cdf0e10cSrcweir 2024*cdf0e10cSrcweir pDoc->RemoveManualBreaks(nTab); 2025*cdf0e10cSrcweir pDoc->UpdatePageBreaks(nTab); 2026*cdf0e10cSrcweir if (pViewShell) 2027*cdf0e10cSrcweir pViewShell->UpdatePageBreakData( sal_True ); 2028*cdf0e10cSrcweir pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID ); 2029*cdf0e10cSrcweir 2030*cdf0e10cSrcweir EndRedo(); 2031*cdf0e10cSrcweir } 2032*cdf0e10cSrcweir 2033*cdf0e10cSrcweir void __EXPORT ScUndoRemoveBreaks::Repeat(SfxRepeatTarget& rTarget) 2034*cdf0e10cSrcweir { 2035*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 2036*cdf0e10cSrcweir { 2037*cdf0e10cSrcweir ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell(); 2038*cdf0e10cSrcweir rViewShell.RemoveManualBreaks(); 2039*cdf0e10cSrcweir } 2040*cdf0e10cSrcweir } 2041*cdf0e10cSrcweir 2042*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoRemoveBreaks::CanRepeat(SfxRepeatTarget& rTarget) const 2043*cdf0e10cSrcweir { 2044*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 2045*cdf0e10cSrcweir } 2046*cdf0e10cSrcweir 2047*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2048*cdf0e10cSrcweir // 2049*cdf0e10cSrcweir // Zusammenfassung aufheben (fuer einen ganzen Bereich) 2050*cdf0e10cSrcweir // 2051*cdf0e10cSrcweir 2052*cdf0e10cSrcweir ScUndoRemoveMerge::ScUndoRemoveMerge( ScDocShell* pNewDocShell, 2053*cdf0e10cSrcweir const ScRange& rArea, ScDocument* pNewUndoDoc ) : 2054*cdf0e10cSrcweir ScBlockUndo( pNewDocShell, rArea, SC_UNDO_SIMPLE ), 2055*cdf0e10cSrcweir pUndoDoc( pNewUndoDoc ) 2056*cdf0e10cSrcweir { 2057*cdf0e10cSrcweir } 2058*cdf0e10cSrcweir 2059*cdf0e10cSrcweir __EXPORT ScUndoRemoveMerge::~ScUndoRemoveMerge() 2060*cdf0e10cSrcweir { 2061*cdf0e10cSrcweir delete pUndoDoc; 2062*cdf0e10cSrcweir } 2063*cdf0e10cSrcweir 2064*cdf0e10cSrcweir String __EXPORT ScUndoRemoveMerge::GetComment() const 2065*cdf0e10cSrcweir { 2066*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_REMERGE ); // "Zusammenfassung aufheben" 2067*cdf0e10cSrcweir } 2068*cdf0e10cSrcweir 2069*cdf0e10cSrcweir void __EXPORT ScUndoRemoveMerge::Undo() 2070*cdf0e10cSrcweir { 2071*cdf0e10cSrcweir BeginUndo(); 2072*cdf0e10cSrcweir 2073*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 2074*cdf0e10cSrcweir 2075*cdf0e10cSrcweir ScRange aExtended = aBlockRange; 2076*cdf0e10cSrcweir pUndoDoc->ExtendMerge( aExtended ); 2077*cdf0e10cSrcweir 2078*cdf0e10cSrcweir pDoc->DeleteAreaTab( aExtended, IDF_ATTRIB ); 2079*cdf0e10cSrcweir pUndoDoc->CopyToDocument( aExtended, IDF_ATTRIB, sal_False, pDoc ); 2080*cdf0e10cSrcweir 2081*cdf0e10cSrcweir sal_Bool bDidPaint = sal_False; 2082*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 2083*cdf0e10cSrcweir if ( pViewShell ) 2084*cdf0e10cSrcweir { 2085*cdf0e10cSrcweir pViewShell->SetTabNo( aExtended.aStart.Tab() ); 2086*cdf0e10cSrcweir bDidPaint = pViewShell->AdjustRowHeight( aExtended.aStart.Row(), aExtended.aEnd.Row() ); 2087*cdf0e10cSrcweir } 2088*cdf0e10cSrcweir if (!bDidPaint) 2089*cdf0e10cSrcweir ScUndoUtil::PaintMore( pDocShell, aExtended ); 2090*cdf0e10cSrcweir 2091*cdf0e10cSrcweir EndUndo(); 2092*cdf0e10cSrcweir } 2093*cdf0e10cSrcweir 2094*cdf0e10cSrcweir void __EXPORT ScUndoRemoveMerge::Redo() 2095*cdf0e10cSrcweir { 2096*cdf0e10cSrcweir BeginRedo(); 2097*cdf0e10cSrcweir 2098*cdf0e10cSrcweir SCTAB nTab = aBlockRange.aStart.Tab(); 2099*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 2100*cdf0e10cSrcweir ScRange aExtended = aBlockRange; 2101*cdf0e10cSrcweir pDoc->ExtendMerge( aExtended ); 2102*cdf0e10cSrcweir ScRange aRefresh = aExtended; 2103*cdf0e10cSrcweir pDoc->ExtendOverlapped( aRefresh ); 2104*cdf0e10cSrcweir 2105*cdf0e10cSrcweir // ausfuehren 2106*cdf0e10cSrcweir 2107*cdf0e10cSrcweir const SfxPoolItem& rDefAttr = pDoc->GetPool()->GetDefaultItem( ATTR_MERGE ); 2108*cdf0e10cSrcweir ScPatternAttr aPattern( pDoc->GetPool() ); 2109*cdf0e10cSrcweir aPattern.GetItemSet().Put( rDefAttr ); 2110*cdf0e10cSrcweir pDoc->ApplyPatternAreaTab( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(), 2111*cdf0e10cSrcweir aBlockRange.aEnd.Col(), aBlockRange.aEnd.Row(), nTab, 2112*cdf0e10cSrcweir aPattern ); 2113*cdf0e10cSrcweir 2114*cdf0e10cSrcweir pDoc->RemoveFlagsTab( aExtended.aStart.Col(), aExtended.aStart.Row(), 2115*cdf0e10cSrcweir aExtended.aEnd.Col(), aExtended.aEnd.Row(), nTab, 2116*cdf0e10cSrcweir SC_MF_HOR | SC_MF_VER ); 2117*cdf0e10cSrcweir 2118*cdf0e10cSrcweir pDoc->ExtendMerge( aRefresh, sal_True, sal_False ); 2119*cdf0e10cSrcweir 2120*cdf0e10cSrcweir // Paint 2121*cdf0e10cSrcweir 2122*cdf0e10cSrcweir sal_Bool bDidPaint = sal_False; 2123*cdf0e10cSrcweir ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell(); 2124*cdf0e10cSrcweir if ( pViewShell ) 2125*cdf0e10cSrcweir { 2126*cdf0e10cSrcweir pViewShell->SetTabNo( aExtended.aStart.Tab() ); 2127*cdf0e10cSrcweir bDidPaint = pViewShell->AdjustRowHeight( aExtended.aStart.Row(), aExtended.aEnd.Row() ); 2128*cdf0e10cSrcweir } 2129*cdf0e10cSrcweir if (!bDidPaint) 2130*cdf0e10cSrcweir ScUndoUtil::PaintMore( pDocShell, aExtended ); 2131*cdf0e10cSrcweir 2132*cdf0e10cSrcweir EndRedo(); 2133*cdf0e10cSrcweir } 2134*cdf0e10cSrcweir 2135*cdf0e10cSrcweir void __EXPORT ScUndoRemoveMerge::Repeat(SfxRepeatTarget& rTarget) 2136*cdf0e10cSrcweir { 2137*cdf0e10cSrcweir if (rTarget.ISA(ScTabViewTarget)) 2138*cdf0e10cSrcweir ((ScTabViewTarget&)rTarget).GetViewShell()->RemoveMerge(); 2139*cdf0e10cSrcweir } 2140*cdf0e10cSrcweir 2141*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoRemoveMerge::CanRepeat(SfxRepeatTarget& rTarget) const 2142*cdf0e10cSrcweir { 2143*cdf0e10cSrcweir return (rTarget.ISA(ScTabViewTarget)); 2144*cdf0e10cSrcweir } 2145*cdf0e10cSrcweir 2146*cdf0e10cSrcweir // ----------------------------------------------------------------------- 2147*cdf0e10cSrcweir // 2148*cdf0e10cSrcweir // nur Umrandung setzen, per ScRangeList (StarOne) 2149*cdf0e10cSrcweir // 2150*cdf0e10cSrcweir 2151*cdf0e10cSrcweir ScRange lcl_TotalRange( const ScRangeList& rRanges ) 2152*cdf0e10cSrcweir { 2153*cdf0e10cSrcweir ScRange aTotal; 2154*cdf0e10cSrcweir sal_uLong nCount = rRanges.Count(); 2155*cdf0e10cSrcweir for (sal_uLong i=0; i<nCount; i++) 2156*cdf0e10cSrcweir { 2157*cdf0e10cSrcweir ScRange aRange = *rRanges.GetObject(i); 2158*cdf0e10cSrcweir if (i==0) 2159*cdf0e10cSrcweir aTotal = aRange; 2160*cdf0e10cSrcweir else 2161*cdf0e10cSrcweir { 2162*cdf0e10cSrcweir if (aRange.aStart.Col() < aTotal.aStart.Col()) 2163*cdf0e10cSrcweir aTotal.aStart.SetCol(aRange.aStart.Col()); 2164*cdf0e10cSrcweir if (aRange.aStart.Row() < aTotal.aStart.Row()) 2165*cdf0e10cSrcweir aTotal.aStart.SetRow(aRange.aStart.Row()); 2166*cdf0e10cSrcweir if (aRange.aStart.Tab() < aTotal.aStart.Tab()) 2167*cdf0e10cSrcweir aTotal.aStart.SetTab(aRange.aStart.Tab()); 2168*cdf0e10cSrcweir if (aRange.aEnd.Col() > aTotal.aEnd.Col()) 2169*cdf0e10cSrcweir aTotal.aEnd.SetCol(aRange.aEnd.Col()); 2170*cdf0e10cSrcweir if (aRange.aEnd.Row() > aTotal.aEnd.Row()) 2171*cdf0e10cSrcweir aTotal.aEnd.SetRow(aRange.aEnd.Row()); 2172*cdf0e10cSrcweir if (aRange.aEnd.Tab() > aTotal.aEnd.Tab()) 2173*cdf0e10cSrcweir aTotal.aEnd.SetTab(aRange.aEnd.Tab()); 2174*cdf0e10cSrcweir } 2175*cdf0e10cSrcweir } 2176*cdf0e10cSrcweir return aTotal; 2177*cdf0e10cSrcweir } 2178*cdf0e10cSrcweir 2179*cdf0e10cSrcweir ScUndoBorder::ScUndoBorder( ScDocShell* pNewDocShell, 2180*cdf0e10cSrcweir const ScRangeList& rRangeList, ScDocument* pNewUndoDoc, 2181*cdf0e10cSrcweir const SvxBoxItem& rNewOuter, const SvxBoxInfoItem& rNewInner ) : 2182*cdf0e10cSrcweir ScBlockUndo( pNewDocShell, lcl_TotalRange(rRangeList), SC_UNDO_SIMPLE ), 2183*cdf0e10cSrcweir pUndoDoc( pNewUndoDoc ) 2184*cdf0e10cSrcweir { 2185*cdf0e10cSrcweir pRanges = new ScRangeList(rRangeList); 2186*cdf0e10cSrcweir pOuter = new SvxBoxItem(rNewOuter); 2187*cdf0e10cSrcweir pInner = new SvxBoxInfoItem(rNewInner); 2188*cdf0e10cSrcweir } 2189*cdf0e10cSrcweir 2190*cdf0e10cSrcweir __EXPORT ScUndoBorder::~ScUndoBorder() 2191*cdf0e10cSrcweir { 2192*cdf0e10cSrcweir delete pUndoDoc; 2193*cdf0e10cSrcweir delete pRanges; 2194*cdf0e10cSrcweir delete pOuter; 2195*cdf0e10cSrcweir delete pInner; 2196*cdf0e10cSrcweir } 2197*cdf0e10cSrcweir 2198*cdf0e10cSrcweir String __EXPORT ScUndoBorder::GetComment() const 2199*cdf0e10cSrcweir { 2200*cdf0e10cSrcweir return ScGlobal::GetRscString( STR_UNDO_SELATTRLINES ); //! eigener String? 2201*cdf0e10cSrcweir } 2202*cdf0e10cSrcweir 2203*cdf0e10cSrcweir void __EXPORT ScUndoBorder::Undo() 2204*cdf0e10cSrcweir { 2205*cdf0e10cSrcweir BeginUndo(); 2206*cdf0e10cSrcweir 2207*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 2208*cdf0e10cSrcweir ScMarkData aMarkData; 2209*cdf0e10cSrcweir aMarkData.MarkFromRangeList( *pRanges, sal_False ); 2210*cdf0e10cSrcweir pUndoDoc->CopyToDocument( aBlockRange, IDF_ATTRIB, sal_True, pDoc, &aMarkData ); 2211*cdf0e10cSrcweir pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); 2212*cdf0e10cSrcweir 2213*cdf0e10cSrcweir EndUndo(); 2214*cdf0e10cSrcweir } 2215*cdf0e10cSrcweir 2216*cdf0e10cSrcweir void __EXPORT ScUndoBorder::Redo() 2217*cdf0e10cSrcweir { 2218*cdf0e10cSrcweir BeginRedo(); 2219*cdf0e10cSrcweir 2220*cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); //! Funktion an docfunc aufrufen 2221*cdf0e10cSrcweir sal_uLong nCount = pRanges->Count(); 2222*cdf0e10cSrcweir sal_uLong i; 2223*cdf0e10cSrcweir for (i=0; i<nCount; i++) 2224*cdf0e10cSrcweir { 2225*cdf0e10cSrcweir ScRange aRange = *pRanges->GetObject(i); 2226*cdf0e10cSrcweir SCTAB nTab = aRange.aStart.Tab(); 2227*cdf0e10cSrcweir 2228*cdf0e10cSrcweir ScMarkData aMark; 2229*cdf0e10cSrcweir aMark.SetMarkArea( aRange ); 2230*cdf0e10cSrcweir aMark.SelectTable( nTab, sal_True ); 2231*cdf0e10cSrcweir 2232*cdf0e10cSrcweir pDoc->ApplySelectionFrame( aMark, pOuter, pInner ); 2233*cdf0e10cSrcweir } 2234*cdf0e10cSrcweir for (i=0; i<nCount; i++) 2235*cdf0e10cSrcweir pDocShell->PostPaint( *pRanges->GetObject(i), PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE ); 2236*cdf0e10cSrcweir 2237*cdf0e10cSrcweir EndRedo(); 2238*cdf0e10cSrcweir } 2239*cdf0e10cSrcweir 2240*cdf0e10cSrcweir void __EXPORT ScUndoBorder::Repeat(SfxRepeatTarget& /* rTarget */) 2241*cdf0e10cSrcweir { 2242*cdf0e10cSrcweir //! spaeter (wenn die Funktion aus cellsuno nach docfunc gewandert ist) 2243*cdf0e10cSrcweir } 2244*cdf0e10cSrcweir 2245*cdf0e10cSrcweir sal_Bool __EXPORT ScUndoBorder::CanRepeat(SfxRepeatTarget& /* rTarget */) const 2246*cdf0e10cSrcweir { 2247*cdf0e10cSrcweir return sal_False; // s.o. 2248*cdf0e10cSrcweir } 2249*cdf0e10cSrcweir 2250*cdf0e10cSrcweir 2251*cdf0e10cSrcweir 2252*cdf0e10cSrcweir 2253