LCOV - code coverage report
Current view: top level - sc/source/ui/undo - undoblk.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 242 1176 20.6 %
Date: 2012-08-25 Functions: 47 229 20.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 203 1428 14.2 %

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

Generated by: LCOV version 1.10