LCOV - code coverage report
Current view: top level - sc/source/ui/undo - undotab.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 169 849 19.9 %
Date: 2014-04-11 Functions: 47 230 20.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sfx2/app.hxx>
      21             : #include <sfx2/bindings.hxx>
      22             : #include <sfx2/dispatch.hxx>
      23             : #include <svl/smplhint.hxx>
      24             : 
      25             : #include "undotab.hxx"
      26             : #include "document.hxx"
      27             : #include "docsh.hxx"
      28             : #include "tabvwsh.hxx"
      29             : #include "globstr.hrc"
      30             : #include "global.hxx"
      31             : #include "sc.hrc"
      32             : #include "undoolk.hxx"
      33             : #include "target.hxx"
      34             : #include "uiitems.hxx"
      35             : #include "prnsave.hxx"
      36             : #include "printfun.hxx"
      37             : #include "chgtrack.hxx"
      38             : #include "tabprotection.hxx"
      39             : #include "viewdata.hxx"
      40             : #include "progress.hxx"
      41             : #include "markdata.hxx"
      42             : 
      43             : // for ScUndoRenameObject - might me moved to another file later
      44             : #include <svx/svditer.hxx>
      45             : #include <svx/svdoole2.hxx>
      46             : #include <svx/svdpage.hxx>
      47             : #include "drwlayer.hxx"
      48             : #include "scresid.hxx"
      49             : 
      50             : #include <vector>
      51             : 
      52             : extern sal_Bool bDrawIsInUndo; // somewhere as member!
      53             : 
      54             : using namespace com::sun::star;
      55             : using ::com::sun::star::uno::Sequence;
      56             : using ::std::auto_ptr;
      57             : using ::std::vector;
      58             : using ::boost::shared_ptr;
      59             : 
      60           0 : TYPEINIT1(ScUndoInsertTab,      SfxUndoAction);
      61           0 : TYPEINIT1(ScUndoInsertTables,   SfxUndoAction);
      62           0 : TYPEINIT1(ScUndoDeleteTab,      SfxUndoAction);
      63           0 : TYPEINIT1(ScUndoRenameTab,      SfxUndoAction);
      64           0 : TYPEINIT1(ScUndoMoveTab,        SfxUndoAction);
      65           0 : TYPEINIT1(ScUndoCopyTab,        SfxUndoAction);
      66           0 : TYPEINIT1(ScUndoMakeScenario,   SfxUndoAction);
      67           0 : TYPEINIT1(ScUndoImportTab,      SfxUndoAction);
      68           0 : TYPEINIT1(ScUndoRemoveLink,     SfxUndoAction);
      69           0 : TYPEINIT1(ScUndoShowHideTab,    SfxUndoAction);
      70           0 : TYPEINIT1(ScUndoPrintRange,     SfxUndoAction);
      71           0 : TYPEINIT1(ScUndoScenarioFlags,  SfxUndoAction);
      72           0 : TYPEINIT1(ScUndoRenameObject,   SfxUndoAction);
      73           0 : TYPEINIT1(ScUndoLayoutRTL,      SfxUndoAction);
      74           0 : TYPEINIT1(ScUndoTabColor,  SfxUndoAction);
      75             : 
      76          36 : ScUndoInsertTab::ScUndoInsertTab( ScDocShell* pNewDocShell,
      77             :                                   SCTAB nTabNum,
      78             :                                   bool bApp,
      79             :                                   const OUString& rNewName) :
      80             :     ScSimpleUndo( pNewDocShell ),
      81             :     sNewName( rNewName ),
      82             :     pDrawUndo( NULL ),
      83             :     nTab( nTabNum ),
      84          36 :     bAppend( bApp )
      85             : {
      86          36 :     pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
      87          36 :     SetChangeTrack();
      88          36 : }
      89             : 
      90         108 : ScUndoInsertTab::~ScUndoInsertTab()
      91             : {
      92          36 :     DeleteSdrUndoAction( pDrawUndo );
      93          72 : }
      94             : 
      95          68 : OUString ScUndoInsertTab::GetComment() const
      96             : {
      97          68 :     if (bAppend)
      98          12 :         return ScGlobal::GetRscString( STR_UNDO_APPEND_TAB );
      99             :     else
     100          56 :         return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB );
     101             : }
     102             : 
     103          36 : void ScUndoInsertTab::SetChangeTrack()
     104             : {
     105          36 :     ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
     106          36 :     if ( pChangeTrack )
     107             :     {
     108           0 :         ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab );
     109           0 :         pChangeTrack->AppendInsert( aRange );
     110           0 :         nEndChangeAction = pChangeTrack->GetActionMax();
     111             :     }
     112             :     else
     113          36 :         nEndChangeAction = 0;
     114          36 : }
     115             : 
     116           0 : void ScUndoInsertTab::Undo()
     117             : {
     118           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     119           0 :     pViewShell->SetTabNo(nTab);
     120             : 
     121           0 :     pDocShell->SetInUndo( true );               //! BeginUndo
     122           0 :     bDrawIsInUndo = sal_True;
     123           0 :     pViewShell->DeleteTable( nTab, false );
     124           0 :     bDrawIsInUndo = false;
     125           0 :     pDocShell->SetInUndo( false );              //! EndUndo
     126             : 
     127           0 :     DoSdrUndoAction( pDrawUndo, pDocShell->GetDocument() );
     128             : 
     129           0 :     ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
     130           0 :     if ( pChangeTrack )
     131           0 :         pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
     132             : 
     133             :     //  SetTabNo(...,sal_True) for all views to sync with drawing layer pages
     134           0 :     pDocShell->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB ) );
     135           0 : }
     136             : 
     137           0 : void ScUndoInsertTab::Redo()
     138             : {
     139           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     140             : 
     141           0 :     RedoSdrUndoAction( pDrawUndo );             // Draw Redo first
     142             : 
     143           0 :     pDocShell->SetInUndo( true );               //! BeginRedo
     144           0 :     bDrawIsInUndo = sal_True;
     145           0 :     if (bAppend)
     146           0 :         pViewShell->AppendTable( sNewName, false );
     147             :     else
     148             :     {
     149           0 :         pViewShell->SetTabNo(nTab);
     150           0 :         pViewShell->InsertTable( sNewName, nTab, false );
     151             :     }
     152           0 :     bDrawIsInUndo = false;
     153           0 :     pDocShell->SetInUndo( false );              //! EndRedo
     154             : 
     155           0 :     SetChangeTrack();
     156           0 : }
     157             : 
     158           0 : void ScUndoInsertTab::Repeat(SfxRepeatTarget& rTarget)
     159             : {
     160           0 :     if (rTarget.ISA(ScTabViewTarget))
     161           0 :         ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
     162           0 :             Execute(FID_INS_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     163           0 : }
     164             : 
     165          18 : bool ScUndoInsertTab::CanRepeat(SfxRepeatTarget& rTarget) const
     166             : {
     167          18 :     return rTarget.ISA(ScTabViewTarget);
     168             : }
     169             : 
     170           0 : ScUndoInsertTables::ScUndoInsertTables( ScDocShell* pNewDocShell,
     171             :                                         SCTAB nTabNum,
     172             :                                         std::vector<OUString>& newNameList) :
     173             :     ScSimpleUndo( pNewDocShell ),
     174             :     pDrawUndo( NULL ),
     175             :     aNameList( newNameList ),
     176           0 :     nTab( nTabNum )
     177             : {
     178           0 :     pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
     179             : 
     180           0 :     SetChangeTrack();
     181           0 : }
     182             : 
     183           0 : ScUndoInsertTables::~ScUndoInsertTables()
     184             : {
     185           0 :     DeleteSdrUndoAction( pDrawUndo );
     186           0 : }
     187             : 
     188           0 : OUString ScUndoInsertTables::GetComment() const
     189             : {
     190           0 :     return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB );
     191             : }
     192             : 
     193           0 : void ScUndoInsertTables::SetChangeTrack()
     194             : {
     195           0 :     ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
     196           0 :     if ( pChangeTrack )
     197             :     {
     198           0 :         nStartChangeAction = pChangeTrack->GetActionMax() + 1;
     199           0 :         nEndChangeAction = 0;
     200           0 :         ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab );
     201           0 :         for( size_t i = 0; i < aNameList.size(); i++ )
     202             :         {
     203           0 :             aRange.aStart.SetTab( sal::static_int_cast<SCTAB>( nTab + i ) );
     204           0 :             aRange.aEnd.SetTab( sal::static_int_cast<SCTAB>( nTab + i ) );
     205           0 :             pChangeTrack->AppendInsert( aRange );
     206           0 :             nEndChangeAction = pChangeTrack->GetActionMax();
     207             :         }
     208             :     }
     209             :     else
     210           0 :         nStartChangeAction = nEndChangeAction = 0;
     211           0 : }
     212             : 
     213           0 : void ScUndoInsertTables::Undo()
     214             : {
     215           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     216           0 :     pViewShell->SetTabNo(nTab);
     217             : 
     218           0 :     pDocShell->SetInUndo( true );               //! BeginUndo
     219           0 :     bDrawIsInUndo = sal_True;
     220             : 
     221           0 :     pViewShell->DeleteTables( nTab, static_cast<SCTAB>(aNameList.size()) );
     222             : 
     223           0 :     bDrawIsInUndo = false;
     224           0 :     pDocShell->SetInUndo( false );              //! EndUndo
     225             : 
     226           0 :     DoSdrUndoAction( pDrawUndo, pDocShell->GetDocument() );
     227             : 
     228           0 :     ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
     229           0 :     if ( pChangeTrack )
     230           0 :         pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
     231             : 
     232             :     //  SetTabNo(...,sal_True) for all views to sync with drawing layer pages
     233           0 :     pDocShell->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB ) );
     234           0 : }
     235             : 
     236           0 : void ScUndoInsertTables::Redo()
     237             : {
     238           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     239             : 
     240           0 :     RedoSdrUndoAction( pDrawUndo );             // Draw Redo first
     241             : 
     242           0 :     pDocShell->SetInUndo( true );               //! BeginRedo
     243           0 :     bDrawIsInUndo = sal_True;
     244           0 :     pViewShell->SetTabNo(nTab);
     245           0 :     pViewShell->InsertTables( aNameList, nTab, static_cast<SCTAB>(aNameList.size()),false );
     246             : 
     247           0 :     bDrawIsInUndo = false;
     248           0 :     pDocShell->SetInUndo( false );              //! EndRedo
     249             : 
     250           0 :     SetChangeTrack();
     251           0 : }
     252             : 
     253           0 : void ScUndoInsertTables::Repeat(SfxRepeatTarget& rTarget)
     254             : {
     255           0 :     if (rTarget.ISA(ScTabViewTarget))
     256           0 :         ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
     257           0 :             Execute(FID_INS_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
     258           0 : }
     259             : 
     260           0 : bool ScUndoInsertTables::CanRepeat(SfxRepeatTarget& rTarget) const
     261             : {
     262           0 :     return rTarget.ISA(ScTabViewTarget);
     263             : }
     264             : 
     265          19 : ScUndoDeleteTab::ScUndoDeleteTab( ScDocShell* pNewDocShell, const vector<SCTAB> &aTab,
     266             :                                     ScDocument* pUndoDocument, ScRefUndoData* pRefData ) :
     267          19 :     ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST )
     268             : {
     269          19 :     theTabs.insert(theTabs.end(), aTab.begin(), aTab.end() );
     270          19 :     SetChangeTrack();
     271          19 : }
     272             : 
     273          54 : ScUndoDeleteTab::~ScUndoDeleteTab()
     274             : {
     275          18 :     theTabs.clear();
     276          36 : }
     277             : 
     278          24 : OUString ScUndoDeleteTab::GetComment() const
     279             : {
     280          24 :     return ScGlobal::GetRscString( STR_UNDO_DELETE_TAB );
     281             : }
     282             : 
     283          19 : void ScUndoDeleteTab::SetChangeTrack()
     284             : {
     285          19 :     ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
     286          19 :     if ( pChangeTrack )
     287             :     {
     288             :         sal_uLong nTmpChangeAction;
     289           0 :         nStartChangeAction = pChangeTrack->GetActionMax() + 1;
     290           0 :         nEndChangeAction = 0;
     291           0 :         ScRange aRange( 0, 0, 0, MAXCOL, MAXROW, 0 );
     292           0 :         for ( unsigned int i = 0; i < theTabs.size(); ++i )
     293             :         {
     294           0 :             aRange.aStart.SetTab( theTabs[i] );
     295           0 :             aRange.aEnd.SetTab( theTabs[i] );
     296             :             pChangeTrack->AppendDeleteRange( aRange, pRefUndoDoc,
     297           0 :                 nTmpChangeAction, nEndChangeAction, (short) i );
     298             :         }
     299             :     }
     300             :     else
     301          19 :         nStartChangeAction = nEndChangeAction = 0;
     302          19 : }
     303             : 
     304           0 : static SCTAB lcl_GetVisibleTabBefore( ScDocument& rDoc, SCTAB nTab )
     305             : {
     306           0 :     while ( nTab > 0 && !rDoc.IsVisible( nTab ) )
     307           0 :         --nTab;
     308             : 
     309           0 :     return nTab;
     310             : }
     311             : 
     312           1 : void ScUndoDeleteTab::Undo()
     313             : {
     314           1 :     BeginUndo();
     315           1 :     unsigned int i=0;
     316           1 :     ScDocument* pDoc = pDocShell->GetDocument();
     317             : 
     318           1 :     bool bLink = false;
     319           1 :     OUString aName;
     320             : 
     321           2 :     for(i=0; i<theTabs.size(); ++i)
     322             :     {
     323           1 :         SCTAB nTab = theTabs[i];
     324           1 :         pRefUndoDoc->GetName( nTab, aName );
     325             : 
     326           1 :         bDrawIsInUndo = true;
     327           1 :         bool bOk = pDoc->InsertTab(nTab, aName, false, true);
     328           1 :         bDrawIsInUndo = false;
     329           1 :         if (bOk)
     330             :         {
     331           1 :             pRefUndoDoc->CopyToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,false, pDoc );
     332             : 
     333           1 :             OUString aOldName;
     334           1 :             pRefUndoDoc->GetName( nTab, aOldName );
     335           1 :             pDoc->RenameTab( nTab, aOldName, false );
     336           1 :             if (pRefUndoDoc->IsLinked(nTab))
     337             :             {
     338           0 :                 pDoc->SetLink( nTab, pRefUndoDoc->GetLinkMode(nTab), pRefUndoDoc->GetLinkDoc(nTab),
     339             :                                      pRefUndoDoc->GetLinkFlt(nTab), pRefUndoDoc->GetLinkOpt(nTab),
     340           0 :                                      pRefUndoDoc->GetLinkTab(nTab), pRefUndoDoc->GetLinkRefreshDelay(nTab) );
     341           0 :                 bLink = true;
     342             :             }
     343             : 
     344           1 :             if ( pRefUndoDoc->IsScenario(nTab) )
     345             :             {
     346           0 :                 pDoc->SetScenario( nTab, true );
     347           0 :                 OUString aComment;
     348           0 :                 Color  aColor;
     349             :                 sal_uInt16 nScenFlags;
     350           0 :                 pRefUndoDoc->GetScenarioData( nTab, aComment, aColor, nScenFlags );
     351           0 :                 pDoc->SetScenarioData( nTab, aComment, aColor, nScenFlags );
     352           0 :                 sal_Bool bActive = pRefUndoDoc->IsActiveScenario( nTab );
     353           0 :                 pDoc->SetActiveScenario( nTab, bActive );
     354             :             }
     355           1 :             pDoc->SetVisible( nTab, pRefUndoDoc->IsVisible( nTab ) );
     356           1 :             pDoc->SetTabBgColor( nTab, pRefUndoDoc->GetTabBgColor(nTab) );
     357           1 :             pDoc->SetSheetEvents( nTab, pRefUndoDoc->GetSheetEvents( nTab ) );
     358           1 :             pDoc->SetLayoutRTL( nTab, pRefUndoDoc->IsLayoutRTL( nTab ) );
     359             : 
     360           1 :             if ( pRefUndoDoc->IsTabProtected( nTab ) )
     361           0 :                 pDoc->SetTabProtection(nTab, pRefUndoDoc->GetTabProtection(nTab));
     362             :         }
     363             :     }
     364           1 :     if (bLink)
     365             :     {
     366           0 :         pDocShell->UpdateLinks(); // update Link Manager
     367             :     }
     368             : 
     369           1 :     EndUndo();      // Draw-Undo has to be called before Broadcast!
     370             : 
     371           1 :     ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
     372           1 :     if ( pChangeTrack )
     373           0 :         pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
     374             : 
     375           2 :     for(i=0; i<theTabs.size(); ++i)
     376             :     {
     377           1 :         pDocShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, theTabs[i]) );
     378             :     }
     379           1 :     SfxApplication* pSfxApp = SFX_APP();                                // Navigator
     380           1 :     pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
     381           1 :     pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
     382           1 :     pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
     383             : 
     384           1 :     pDocShell->PostPaint(0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_ALL );  // incl. extras
     385             : 
     386             :     // not ShowTable due to SetTabNo(..., sal_True):
     387           1 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     388           1 :     if (pViewShell)
     389           0 :         pViewShell->SetTabNo( lcl_GetVisibleTabBefore( *pDoc, theTabs[0] ), true );
     390           1 : }
     391             : 
     392           0 : void ScUndoDeleteTab::Redo()
     393             : {
     394           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     395           0 :     pViewShell->SetTabNo( lcl_GetVisibleTabBefore( *pDocShell->GetDocument(), theTabs.front() ) );
     396             : 
     397           0 :     RedoSdrUndoAction( pDrawUndo );             // Draw Redo first
     398             : 
     399           0 :     pDocShell->SetInUndo( true );               //! BeginRedo
     400           0 :     bDrawIsInUndo = sal_True;
     401           0 :     pViewShell->DeleteTables( theTabs, false );
     402           0 :     bDrawIsInUndo = false;
     403           0 :     pDocShell->SetInUndo( true );               //! EndRedo
     404             : 
     405           0 :     SetChangeTrack();
     406             : 
     407             :     //  SetTabNo(...,sal_True) for all views to sync with drawing layer pages
     408           0 :     pDocShell->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB ) );
     409           0 : }
     410             : 
     411           0 : void ScUndoDeleteTab::Repeat(SfxRepeatTarget& rTarget)
     412             : {
     413           0 :     if (rTarget.ISA(ScTabViewTarget))
     414             :     {
     415           0 :         ScTabViewShell* pViewShell = ((ScTabViewTarget&)rTarget).GetViewShell();
     416           0 :         pViewShell->DeleteTable( pViewShell->GetViewData()->GetTabNo(), true );
     417             :     }
     418           0 : }
     419             : 
     420           2 : bool ScUndoDeleteTab::CanRepeat(SfxRepeatTarget& rTarget) const
     421             : {
     422           2 :     return rTarget.ISA(ScTabViewTarget);
     423             : }
     424             : 
     425           3 : ScUndoRenameTab::ScUndoRenameTab( ScDocShell* pNewDocShell,
     426             :                                   SCTAB nT,
     427             :                                   const OUString& rOldName,
     428             :                                   const OUString& rNewName) :
     429             :     ScSimpleUndo( pNewDocShell ),
     430           3 :     nTab     ( nT )
     431             : {
     432           3 :     sOldName = rOldName;
     433           3 :     sNewName = rNewName;
     434           3 : }
     435             : 
     436           4 : ScUndoRenameTab::~ScUndoRenameTab()
     437             : {
     438           4 : }
     439             : 
     440           4 : OUString ScUndoRenameTab::GetComment() const
     441             : {
     442           4 :     return ScGlobal::GetRscString( STR_UNDO_RENAME_TAB );
     443             : }
     444             : 
     445           2 : void ScUndoRenameTab::DoChange( SCTAB nTabP, const OUString& rName ) const
     446             : {
     447           2 :     ScDocument* pDoc = pDocShell->GetDocument();
     448           2 :     pDoc->RenameTab( nTabP, rName );
     449             : 
     450           2 :     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );    // Navigator
     451             : 
     452           2 :     pDocShell->PostPaintGridAll();
     453           2 :     pDocShell->PostPaintExtras();
     454           2 :     pDocShell->PostDataChanged();
     455             : 
     456             :     // The sheet name might be used in a formula ...
     457           2 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     458           2 :     if (pViewShell)
     459           0 :         pViewShell->UpdateInputHandler();
     460           2 : }
     461             : 
     462           1 : void ScUndoRenameTab::Undo()
     463             : {
     464           1 :     DoChange(nTab, sOldName);
     465           1 : }
     466             : 
     467           1 : void ScUndoRenameTab::Redo()
     468             : {
     469           1 :     DoChange(nTab, sNewName);
     470           1 : }
     471             : 
     472           0 : void ScUndoRenameTab::Repeat(SfxRepeatTarget& /* rTarget */)
     473             : {
     474             :     // makes no sense
     475           0 : }
     476             : 
     477           2 : bool ScUndoRenameTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
     478             : {
     479           2 :     return false;
     480             : }
     481             : 
     482           0 : ScUndoMoveTab::ScUndoMoveTab(
     483             :     ScDocShell* pNewDocShell, vector<SCTAB>* pOldTabs, vector<SCTAB>* pNewTabs,
     484             :     vector<OUString>* pOldNames, vector<OUString>* pNewNames) :
     485             :     ScSimpleUndo( pNewDocShell ),
     486             :     mpOldTabs(pOldTabs), mpNewTabs(pNewTabs),
     487           0 :     mpOldNames(pOldNames), mpNewNames(pNewNames)
     488             : {
     489           0 :     if (mpOldNames && mpOldTabs->size() != mpOldNames->size())
     490             :         // The sizes differ.  Something is wrong.
     491           0 :         mpOldNames.reset();
     492             : 
     493           0 :     if (mpNewNames && mpNewTabs->size() != mpNewNames->size())
     494             :         // The sizes differ.  Something is wrong.
     495           0 :         mpNewNames.reset();
     496           0 : }
     497             : 
     498           0 : ScUndoMoveTab::~ScUndoMoveTab()
     499             : {
     500           0 : }
     501             : 
     502           0 : OUString ScUndoMoveTab::GetComment() const
     503             : {
     504           0 :     return ScGlobal::GetRscString( STR_UNDO_MOVE_TAB );
     505             : }
     506             : 
     507           0 : void ScUndoMoveTab::DoChange( bool bUndo ) const
     508             : {
     509           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     510           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     511             : 
     512           0 :     if (bUndo)                                      // UnDo
     513             :     {
     514           0 :         size_t i = mpNewTabs->size();
     515             :         ScProgress* pProgress = new ScProgress(pDocShell , ScGlobal::GetRscString(STR_UNDO_MOVE_TAB),
     516           0 :                                                 i * pDoc->GetCodeCount());
     517           0 :         for (; i > 0; --i)
     518             :         {
     519           0 :             SCTAB nDestTab = (*mpNewTabs)[i-1];
     520           0 :             SCTAB nOldTab = (*mpOldTabs)[i-1];
     521           0 :             if (nDestTab > MAXTAB)                          // appended ?
     522           0 :                 nDestTab = pDoc->GetTableCount() - 1;
     523             : 
     524           0 :             pDoc->MoveTab( nDestTab, nOldTab, pProgress );
     525           0 :             pViewShell->GetViewData()->MoveTab( nDestTab, nOldTab );
     526           0 :             pViewShell->SetTabNo( nOldTab, true );
     527           0 :             if (mpOldNames)
     528             :             {
     529           0 :                 const OUString& rOldName = (*mpOldNames)[i-1];
     530           0 :                 pDoc->RenameTab(nOldTab, rOldName);
     531             :             }
     532             :         }
     533           0 :         delete pProgress;
     534             :     }
     535             :     else
     536             :     {
     537           0 :         size_t n = mpNewTabs->size();
     538             :         ScProgress* pProgress = new ScProgress(pDocShell , ScGlobal::GetRscString(STR_UNDO_MOVE_TAB),
     539           0 :                                                 n * pDoc->GetCodeCount());
     540           0 :         for (size_t i = 0; i < n; ++i)
     541             :         {
     542           0 :             SCTAB nDestTab = (*mpNewTabs)[i];
     543           0 :             SCTAB nNewTab = nDestTab;
     544           0 :             SCTAB nOldTab = (*mpOldTabs)[i];
     545           0 :             if (nDestTab > MAXTAB)                          // appended ?
     546           0 :                 nDestTab = pDoc->GetTableCount() - 1;
     547             : 
     548           0 :             pDoc->MoveTab( nOldTab, nNewTab, pProgress );
     549           0 :             pViewShell->GetViewData()->MoveTab( nOldTab, nNewTab );
     550           0 :             pViewShell->SetTabNo( nDestTab, true );
     551           0 :             if (mpNewNames)
     552             :             {
     553           0 :                 const OUString& rNewName = (*mpNewNames)[i];
     554           0 :                 pDoc->RenameTab(nNewTab, rNewName);
     555             :             }
     556             :         }
     557           0 :         delete pProgress;
     558             :     }
     559             : 
     560           0 :     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );    // Navigator
     561             : 
     562           0 :     pDocShell->PostPaintGridAll();
     563           0 :     pDocShell->PostPaintExtras();
     564           0 :     pDocShell->PostDataChanged();
     565           0 : }
     566             : 
     567           0 : void ScUndoMoveTab::Undo()
     568             : {
     569           0 :     DoChange( true );
     570           0 : }
     571             : 
     572           0 : void ScUndoMoveTab::Redo()
     573             : {
     574           0 :     DoChange( false );
     575           0 : }
     576             : 
     577           0 : void ScUndoMoveTab::Repeat(SfxRepeatTarget& /* rTarget */)
     578             : {
     579             :         // No Repeat ! ? !
     580           0 : }
     581             : 
     582           0 : bool ScUndoMoveTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
     583             : {
     584           0 :     return false;
     585             : }
     586             : 
     587           0 : ScUndoCopyTab::ScUndoCopyTab(
     588             :     ScDocShell* pNewDocShell,
     589             :     vector<SCTAB>* pOldTabs, vector<SCTAB>* pNewTabs,
     590             :     vector<OUString>* pNewNames) :
     591             :     ScSimpleUndo( pNewDocShell ),
     592             :     mpOldTabs(pOldTabs),
     593             :     mpNewTabs(pNewTabs),
     594             :     mpNewNames(pNewNames),
     595           0 :     pDrawUndo( NULL )
     596             : {
     597           0 :     pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
     598             : 
     599           0 :     if (mpNewNames && mpNewTabs->size() != mpNewNames->size())
     600             :         // The sizes differ.  Something is wrong.
     601           0 :         mpNewNames.reset();
     602           0 : }
     603             : 
     604           0 : ScUndoCopyTab::~ScUndoCopyTab()
     605             : {
     606           0 :     DeleteSdrUndoAction( pDrawUndo );
     607           0 : }
     608             : 
     609           0 : OUString ScUndoCopyTab::GetComment() const
     610             : {
     611           0 :     return ScGlobal::GetRscString( STR_UNDO_COPY_TAB );
     612             : }
     613             : 
     614           0 : void ScUndoCopyTab::DoChange() const
     615             : {
     616           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     617             : 
     618           0 :     if (pViewShell)
     619           0 :         pViewShell->SetTabNo((*mpOldTabs)[0],true);
     620             : 
     621           0 :     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );    // Navigator
     622             : 
     623           0 :     pDocShell->PostPaintGridAll();
     624           0 :     pDocShell->PostPaintExtras();
     625           0 :     pDocShell->PostDataChanged();
     626           0 : }
     627             : 
     628           0 : void ScUndoCopyTab::Undo()
     629             : {
     630           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     631             : 
     632           0 :     DoSdrUndoAction( pDrawUndo, pDoc );                 // before the sheets are deleted
     633             : 
     634           0 :     vector<SCTAB>::const_reverse_iterator itr, itrEnd = mpNewTabs->rend();
     635           0 :     for (itr = mpNewTabs->rbegin(); itr != itrEnd; ++itr)
     636             :     {
     637           0 :         SCTAB nDestTab = *itr;
     638           0 :         if (nDestTab > MAXTAB)                          // append?
     639           0 :             nDestTab = pDoc->GetTableCount() - 1;
     640             : 
     641           0 :         bDrawIsInUndo = sal_True;
     642           0 :         pDoc->DeleteTab(nDestTab);
     643           0 :         bDrawIsInUndo = false;
     644             :     }
     645             : 
     646             :     //  ScTablesHint broadcasts after all sheets have been deleted,
     647             :     //  so sheets and draw pages are in sync!
     648             : 
     649           0 :     for (itr = mpNewTabs->rbegin(); itr != itrEnd; ++itr)
     650             :     {
     651           0 :         SCTAB nDestTab = *itr;
     652           0 :         if (nDestTab > MAXTAB)                          // append?
     653           0 :             nDestTab = pDoc->GetTableCount() - 1;
     654             : 
     655           0 :         pDocShell->Broadcast( ScTablesHint( SC_TAB_DELETED, nDestTab ) );
     656             :     }
     657             : 
     658           0 :     DoChange();
     659           0 : }
     660             : 
     661           0 : void ScUndoCopyTab::Redo()
     662             : {
     663           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     664           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     665             : 
     666           0 :     SCTAB nDestTab = 0;
     667           0 :     for (size_t i = 0, n = mpNewTabs->size(); i < n; ++i)
     668             :     {
     669           0 :         nDestTab = (*mpNewTabs)[i];
     670           0 :         SCTAB nNewTab = nDestTab;
     671           0 :         SCTAB nOldTab = (*mpOldTabs)[i];
     672           0 :         if (nDestTab > MAXTAB)                          // appended ?
     673           0 :             nDestTab = pDoc->GetTableCount() - 1;
     674             : 
     675           0 :         bDrawIsInUndo = sal_True;
     676           0 :         pDoc->CopyTab( nOldTab, nNewTab );
     677           0 :         bDrawIsInUndo = false;
     678             : 
     679           0 :         pViewShell->GetViewData()->MoveTab( nOldTab, nNewTab );
     680             : 
     681           0 :         SCTAB nAdjSource = nOldTab;
     682           0 :         if ( nNewTab <= nOldTab )
     683           0 :             ++nAdjSource;               // new position of source table after CopyTab
     684             : 
     685           0 :         if ( pDoc->IsScenario(nAdjSource) )
     686             :         {
     687           0 :             pDoc->SetScenario(nNewTab, true );
     688           0 :             OUString aComment;
     689           0 :             Color  aColor;
     690             :             sal_uInt16 nScenFlags;
     691           0 :             pDoc->GetScenarioData(nAdjSource, aComment, aColor, nScenFlags );
     692           0 :             pDoc->SetScenarioData(nNewTab, aComment, aColor, nScenFlags );
     693           0 :             sal_Bool bActive = pDoc->IsActiveScenario(nAdjSource);
     694           0 :             pDoc->SetActiveScenario(nNewTab, bActive );
     695           0 :             sal_Bool bVisible=pDoc->IsVisible(nAdjSource);
     696           0 :             pDoc->SetVisible(nNewTab,bVisible );
     697             :         }
     698             : 
     699           0 :         if ( pDoc->IsTabProtected( nAdjSource ) )
     700           0 :             pDoc->CopyTabProtection(nAdjSource, nNewTab);
     701             : 
     702           0 :         if (mpNewNames)
     703             :         {
     704           0 :             const OUString& rName = (*mpNewNames)[i];
     705           0 :             pDoc->RenameTab(nNewTab, rName);
     706             :         }
     707             :     }
     708             : 
     709           0 :     RedoSdrUndoAction( pDrawUndo );             // after the sheets are inserted
     710             : 
     711           0 :     pViewShell->SetTabNo( nDestTab, true );     // after draw-undo
     712             : 
     713           0 :     DoChange();
     714             : 
     715           0 : }
     716             : 
     717           0 : void ScUndoCopyTab::Repeat(SfxRepeatTarget& /* rTarget */)
     718             : {
     719             :         // no Repeat ! ? !
     720           0 : }
     721             : 
     722           0 : bool ScUndoCopyTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
     723             : {
     724           0 :     return false;
     725             : }
     726             : 
     727             : 
     728           1 : ScUndoTabColor::ScUndoTabColor(
     729             :     ScDocShell* pNewDocShell, SCTAB nT, const Color& aOTabBgColor, const Color& aNTabBgColor) :
     730           1 :     ScSimpleUndo( pNewDocShell )
     731             : {
     732           1 :     ScUndoTabColorInfo aInfo(nT);
     733           1 :     aInfo.maOldTabBgColor = aOTabBgColor;
     734           1 :     aInfo.maNewTabBgColor = aNTabBgColor;
     735           1 :     aTabColorList.push_back(aInfo);
     736           1 : }
     737             : 
     738           0 : ScUndoTabColor::ScUndoTabColor(
     739             :     ScDocShell* pNewDocShell,
     740             :     const ScUndoTabColorInfo::List& rUndoTabColorList) :
     741             :     ScSimpleUndo(pNewDocShell),
     742           0 :     aTabColorList(rUndoTabColorList)
     743             : {
     744           0 : }
     745             : 
     746           0 : ScUndoTabColor::~ScUndoTabColor()
     747             : {
     748           0 : }
     749             : 
     750           0 : OUString ScUndoTabColor::GetComment() const
     751             : {
     752           0 :     if (aTabColorList.size() > 1)
     753           0 :         return ScGlobal::GetRscString(STR_UNDO_SET_MULTI_TAB_BG_COLOR);
     754           0 :     return ScGlobal::GetRscString(STR_UNDO_SET_TAB_BG_COLOR);
     755             : }
     756             : 
     757           2 : void ScUndoTabColor::DoChange(bool bUndoType) const
     758             : {
     759           2 :     ScDocument* pDoc = pDocShell->GetDocument();
     760           2 :     if (!pDoc)
     761           2 :         return;
     762             : 
     763           2 :     size_t nTabColorCount = aTabColorList.size();
     764           4 :     for (size_t i = 0; i < nTabColorCount; ++i)
     765             :     {
     766           2 :         const ScUndoTabColorInfo& rTabColor = aTabColorList[i];
     767             :         pDoc->SetTabBgColor(rTabColor.mnTabId,
     768           2 :             bUndoType ? rTabColor.maOldTabBgColor : rTabColor.maNewTabBgColor);
     769             :     }
     770             : 
     771           2 :     pDocShell->PostPaintExtras();
     772           2 :     ScDocShellModificator aModificator( *pDocShell );
     773           2 :     aModificator.SetDocumentModified();
     774             : }
     775             : 
     776           1 : void ScUndoTabColor::Undo()
     777             : {
     778           1 :     DoChange(true);
     779           1 : }
     780             : 
     781           1 : void ScUndoTabColor::Redo()
     782             : {
     783           1 :     DoChange(false);
     784           1 : }
     785             : 
     786           0 : void ScUndoTabColor::Repeat(SfxRepeatTarget& /* rTarget */)
     787             : {
     788             :     // makes no sense
     789           0 : }
     790             : 
     791           0 : bool ScUndoTabColor::CanRepeat(SfxRepeatTarget& /* rTarget */) const
     792             : {
     793           0 :     return false;
     794             : }
     795             : 
     796           1 : ScUndoMakeScenario::ScUndoMakeScenario( ScDocShell* pNewDocShell,
     797             :                         SCTAB nSrc, SCTAB nDest,
     798             :                         const OUString& rN, const OUString& rC,
     799             :                         const Color& rCol, sal_uInt16 nF,
     800             :                         const ScMarkData& rMark ) :
     801             :     ScSimpleUndo( pNewDocShell ),
     802           1 :     mpMarkData(new ScMarkData(rMark)),
     803             :     nSrcTab( nSrc ),
     804             :     nDestTab( nDest ),
     805             :     aName( rN ),
     806             :     aComment( rC ),
     807             :     aColor( rCol ),
     808             :     nFlags( nF ),
     809           2 :     pDrawUndo( NULL )
     810             : {
     811           1 :     pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
     812           1 : }
     813             : 
     814           3 : ScUndoMakeScenario::~ScUndoMakeScenario()
     815             : {
     816           1 :     DeleteSdrUndoAction( pDrawUndo );
     817           2 : }
     818             : 
     819           1 : OUString ScUndoMakeScenario::GetComment() const
     820             : {
     821           1 :     return ScGlobal::GetRscString( STR_UNDO_MAKESCENARIO );
     822             : }
     823             : 
     824           0 : void ScUndoMakeScenario::Undo()
     825             : {
     826           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     827             : 
     828           0 :     pDocShell->SetInUndo( true );
     829           0 :     bDrawIsInUndo = sal_True;
     830           0 :     pDoc->DeleteTab( nDestTab );
     831           0 :     bDrawIsInUndo = false;
     832           0 :     pDocShell->SetInUndo( false );
     833             : 
     834           0 :     DoSdrUndoAction( pDrawUndo, pDoc );
     835             : 
     836           0 :     pDocShell->PostPaint(0,0,nDestTab,MAXCOL,MAXROW,MAXTAB, PAINT_ALL);
     837           0 :     pDocShell->PostDataChanged();
     838             : 
     839           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     840           0 :     if (pViewShell)
     841           0 :         pViewShell->SetTabNo( nSrcTab, true );
     842             : 
     843           0 :     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
     844             : 
     845             :     //  SetTabNo(...,sal_True) for all views to sync with drawing layer pages
     846           0 :     pDocShell->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB ) );
     847           0 : }
     848             : 
     849           0 : void ScUndoMakeScenario::Redo()
     850             : {
     851           0 :     SetViewMarkData(*mpMarkData);
     852             : 
     853           0 :     RedoSdrUndoAction( pDrawUndo );             // Draw Redo first
     854             : 
     855           0 :     pDocShell->SetInUndo( true );
     856           0 :     bDrawIsInUndo = sal_True;
     857             : 
     858           0 :     pDocShell->MakeScenario( nSrcTab, aName, aComment, aColor, nFlags, *mpMarkData, false );
     859             : 
     860           0 :     bDrawIsInUndo = false;
     861           0 :     pDocShell->SetInUndo( false );
     862             : 
     863           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     864           0 :     if (pViewShell)
     865           0 :         pViewShell->SetTabNo( nDestTab, true );
     866             : 
     867           0 :     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
     868           0 : }
     869             : 
     870           0 : void ScUndoMakeScenario::Repeat(SfxRepeatTarget& rTarget)
     871             : {
     872           0 :     if (rTarget.ISA(ScTabViewTarget))
     873             :     {
     874           0 :         ((ScTabViewTarget&)rTarget).GetViewShell()->MakeScenario( aName, aComment, aColor, nFlags );
     875             :     }
     876           0 : }
     877             : 
     878           0 : bool ScUndoMakeScenario::CanRepeat(SfxRepeatTarget& rTarget) const
     879             : {
     880           0 :     return rTarget.ISA(ScTabViewTarget);
     881             : }
     882             : 
     883           0 : ScUndoImportTab::ScUndoImportTab( ScDocShell* pShell,
     884             :                         SCTAB nNewTab, SCTAB nNewCount ) :
     885             :     ScSimpleUndo( pShell ),
     886             :     nTab( nNewTab ),
     887             :     nCount( nNewCount ),
     888             :     pRedoDoc( NULL ),
     889           0 :     pDrawUndo( NULL )
     890             : {
     891           0 :     pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
     892           0 : }
     893             : 
     894           0 : ScUndoImportTab::~ScUndoImportTab()
     895             : {
     896           0 :     delete pRedoDoc;
     897           0 :     DeleteSdrUndoAction( pDrawUndo );
     898           0 : }
     899             : 
     900           0 : OUString ScUndoImportTab::GetComment() const
     901             : {
     902           0 :     return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB );
     903             : }
     904             : 
     905           0 : void ScUndoImportTab::DoChange() const
     906             : {
     907           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     908           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     909           0 :     SCTAB nTabCount = pDoc->GetTableCount();
     910           0 :     if (pViewShell)
     911             :     {
     912           0 :         if(nTab<nTabCount)
     913             :         {
     914           0 :             pViewShell->SetTabNo(nTab,true);
     915             :         }
     916             :         else
     917             :         {
     918           0 :             pViewShell->SetTabNo(nTab-1,true);
     919             :         }
     920             :     }
     921             : 
     922           0 :     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );    // Navigator
     923             :     pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB,
     924           0 :                                 PAINT_GRID | PAINT_TOP | PAINT_LEFT | PAINT_EXTRAS );
     925           0 : }
     926             : 
     927           0 : void ScUndoImportTab::Undo()
     928             : {
     929             :     // Inserted range names, etc.
     930             : 
     931             :     SCTAB i;
     932           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     933           0 :     sal_Bool bMakeRedo = !pRedoDoc;
     934           0 :     if (bMakeRedo)
     935             :     {
     936           0 :         pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
     937           0 :         pRedoDoc->InitUndo( pDoc, nTab,nTab+nCount-1, true,true );
     938             : 
     939           0 :         OUString aOldName;
     940           0 :         for (i=0; i<nCount; i++)
     941             :         {
     942           0 :             SCTAB nTabPos=nTab+i;
     943             : 
     944           0 :             pDoc->CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, IDF_ALL,false, pRedoDoc );
     945           0 :             pDoc->GetName( nTabPos, aOldName );
     946           0 :             pRedoDoc->RenameTab( nTabPos, aOldName, false );
     947           0 :             pRedoDoc->SetTabBgColor( nTabPos, pDoc->GetTabBgColor(nTabPos) );
     948             : 
     949           0 :             if ( pDoc->IsScenario(nTabPos) )
     950             :             {
     951           0 :                 pRedoDoc->SetScenario(nTabPos, true );
     952           0 :                 OUString aComment;
     953           0 :                 Color  aColor;
     954             :                 sal_uInt16 nScenFlags;
     955           0 :                 pDoc->GetScenarioData(nTabPos, aComment, aColor, nScenFlags );
     956           0 :                 pRedoDoc->SetScenarioData(nTabPos, aComment, aColor, nScenFlags );
     957           0 :                 sal_Bool bActive = pDoc->IsActiveScenario(nTabPos);
     958           0 :                 pRedoDoc->SetActiveScenario(nTabPos, bActive );
     959           0 :                 sal_Bool bVisible=pDoc->IsVisible(nTabPos);
     960           0 :                 pRedoDoc->SetVisible(nTabPos,bVisible );
     961             :             }
     962             : 
     963           0 :             if ( pDoc->IsTabProtected( nTabPos ) )
     964           0 :                 pRedoDoc->SetTabProtection(nTabPos, pDoc->GetTabProtection(nTabPos));
     965           0 :         }
     966             : 
     967             :     }
     968             : 
     969           0 :     DoSdrUndoAction( pDrawUndo, pDoc );             // before the sheets are deleted
     970             : 
     971           0 :     bDrawIsInUndo = sal_True;
     972           0 :     for (i=0; i<nCount; i++)
     973           0 :         pDoc->DeleteTab( nTab );
     974           0 :     bDrawIsInUndo = false;
     975             : 
     976           0 :     DoChange();
     977           0 : }
     978             : 
     979           0 : void ScUndoImportTab::Redo()
     980             : {
     981           0 :     if (!pRedoDoc)
     982             :     {
     983             :         OSL_FAIL("Where is my Redo Document?");
     984           0 :         return;
     985             :     }
     986             : 
     987           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     988           0 :     OUString aName;
     989             :     SCTAB i;
     990           0 :     for (i=0; i<nCount; i++)                // first insert all sheets (#63304#)
     991             :     {
     992           0 :         SCTAB nTabPos=nTab+i;
     993           0 :         pRedoDoc->GetName(nTabPos,aName);
     994           0 :         bDrawIsInUndo = sal_True;
     995           0 :         pDoc->InsertTab(nTabPos,aName);
     996           0 :         bDrawIsInUndo = false;
     997             :     }
     998           0 :     for (i=0; i<nCount; i++)                // then copy into inserted sheets
     999             :     {
    1000           0 :         SCTAB nTabPos=nTab+i;
    1001           0 :         pRedoDoc->CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, IDF_ALL,false, pDoc );
    1002           0 :         pDoc->SetTabBgColor( nTabPos, pRedoDoc->GetTabBgColor(nTabPos) );
    1003             : 
    1004           0 :         if ( pRedoDoc->IsScenario(nTabPos) )
    1005             :         {
    1006           0 :             pDoc->SetScenario(nTabPos, true );
    1007           0 :             OUString aComment;
    1008           0 :             Color  aColor;
    1009             :             sal_uInt16 nScenFlags;
    1010           0 :             pRedoDoc->GetScenarioData(nTabPos, aComment, aColor, nScenFlags );
    1011           0 :             pDoc->SetScenarioData(nTabPos, aComment, aColor, nScenFlags );
    1012           0 :             sal_Bool bActive = pRedoDoc->IsActiveScenario(nTabPos);
    1013           0 :             pDoc->SetActiveScenario(nTabPos, bActive );
    1014           0 :             sal_Bool bVisible=pRedoDoc->IsVisible(nTabPos);
    1015           0 :             pDoc->SetVisible(nTabPos,bVisible );
    1016             :         }
    1017             : 
    1018           0 :         if ( pRedoDoc->IsTabProtected( nTabPos ) )
    1019           0 :             pDoc->SetTabProtection(nTabPos, pRedoDoc->GetTabProtection(nTabPos));
    1020             :     }
    1021             : 
    1022           0 :     RedoSdrUndoAction( pDrawUndo );     // after the sheets are inserted
    1023             : 
    1024           0 :     DoChange();
    1025             : }
    1026             : 
    1027           0 : void ScUndoImportTab::Repeat(SfxRepeatTarget& rTarget)
    1028             : {
    1029           0 :     if (rTarget.ISA(ScTabViewTarget))
    1030           0 :         ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
    1031           0 :             Execute(FID_INS_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
    1032           0 : }
    1033             : 
    1034           0 : bool ScUndoImportTab::CanRepeat(SfxRepeatTarget& rTarget) const
    1035             : {
    1036           0 :     return rTarget.ISA(ScTabViewTarget);
    1037             : }
    1038             : 
    1039           0 : ScUndoRemoveLink::ScUndoRemoveLink( ScDocShell* pShell, const OUString& rDoc ) :
    1040             :     ScSimpleUndo( pShell ),
    1041             :     aDocName( rDoc ),
    1042             :     nRefreshDelay( 0 ),
    1043           0 :     nCount( 0 )
    1044             : {
    1045           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1046           0 :     SCTAB nTabCount = pDoc->GetTableCount();
    1047           0 :     pTabs     = new SCTAB[nTabCount];
    1048           0 :     pModes    = new sal_uInt8[nTabCount];
    1049           0 :     pTabNames = new OUString[nTabCount];
    1050             : 
    1051           0 :     for (SCTAB i=0; i<nTabCount; i++)
    1052             :     {
    1053           0 :         sal_uInt8 nMode = pDoc->GetLinkMode(i);
    1054           0 :         if (nMode)
    1055           0 :             if (pDoc->GetLinkDoc(i) == aDocName)
    1056             :             {
    1057           0 :                 if (!nCount)
    1058             :                 {
    1059           0 :                     aFltName = pDoc->GetLinkFlt(i);
    1060           0 :                     aOptions = pDoc->GetLinkOpt(i);
    1061           0 :                     nRefreshDelay = pDoc->GetLinkRefreshDelay(i);
    1062             :                 }
    1063             :                 else
    1064             :                 {
    1065             :                     OSL_ENSURE(OUString(aFltName) == pDoc->GetLinkFlt(i) &&
    1066             :                                OUString(aOptions) == pDoc->GetLinkOpt(i),
    1067             :                                     "different Filter for a Document?");
    1068             :                 }
    1069           0 :                 pTabs[nCount] = i;
    1070           0 :                 pModes[nCount] = nMode;
    1071           0 :                 pTabNames[nCount] = pDoc->GetLinkTab(i);
    1072           0 :                 ++nCount;
    1073             :             }
    1074             :     }
    1075           0 : }
    1076             : 
    1077           0 : ScUndoRemoveLink::~ScUndoRemoveLink()
    1078             : {
    1079           0 :     delete pTabs;
    1080           0 :     delete pModes;
    1081           0 :     delete[] pTabNames;
    1082           0 : }
    1083             : 
    1084           0 : OUString ScUndoRemoveLink::GetComment() const
    1085             : {
    1086           0 :     return ScGlobal::GetRscString( STR_UNDO_REMOVELINK );
    1087             : }
    1088             : 
    1089           0 : void ScUndoRemoveLink::DoChange( bool bLink ) const
    1090             : {
    1091           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1092           0 :     OUString aEmpty;
    1093           0 :     for (sal_uInt16 i=0; i<nCount; i++)
    1094           0 :         if (bLink)      // establish link
    1095           0 :             pDoc->SetLink( pTabs[i], pModes[i], aDocName, aFltName, aOptions, pTabNames[i], nRefreshDelay );
    1096             :         else            // remove link
    1097           0 :             pDoc->SetLink( pTabs[i], SC_LINK_NONE, aEmpty, aEmpty, aEmpty, aEmpty, 0 );
    1098           0 :     pDocShell->UpdateLinks();
    1099           0 : }
    1100             : 
    1101           0 : void ScUndoRemoveLink::Undo()
    1102             : {
    1103           0 :     DoChange( true );
    1104           0 : }
    1105             : 
    1106           0 : void ScUndoRemoveLink::Redo()
    1107             : {
    1108           0 :     DoChange( false );
    1109           0 : }
    1110             : 
    1111           0 : void ScUndoRemoveLink::Repeat(SfxRepeatTarget& /* rTarget */)
    1112             : {
    1113             :     // makes no sense
    1114           0 : }
    1115             : 
    1116           0 : bool ScUndoRemoveLink::CanRepeat(SfxRepeatTarget& /* rTarget */) const
    1117             : {
    1118           0 :     return false;
    1119             : }
    1120             : 
    1121           2 : ScUndoShowHideTab::ScUndoShowHideTab( ScDocShell* pShell, const std::vector<SCTAB>& newUndoTabs, bool bNewShow ) :
    1122             :     ScSimpleUndo( pShell ),
    1123             :     undoTabs( newUndoTabs ),
    1124           2 :     bShow( bNewShow )
    1125             : {
    1126           2 : }
    1127             : 
    1128           4 : ScUndoShowHideTab::~ScUndoShowHideTab()
    1129             : {
    1130           4 : }
    1131             : 
    1132           0 : void ScUndoShowHideTab::DoChange( bool bShowP ) const
    1133             : {
    1134           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1135           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1136             : 
    1137             :     SCTAB nTab;
    1138             : 
    1139           0 :     for(std::vector<SCTAB>::const_iterator itr = undoTabs.begin(), itrEnd = undoTabs.end(); itr != itrEnd; ++itr)
    1140             :     {
    1141           0 :         nTab = *itr;
    1142           0 :         pDoc->SetVisible( nTab, bShowP );
    1143           0 :         if (pViewShell)
    1144           0 :             pViewShell->SetTabNo(nTab,true);
    1145             :     }
    1146             : 
    1147           0 :     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
    1148           0 :     pDocShell->SetDocumentModified();
    1149           0 : }
    1150             : 
    1151           0 : void ScUndoShowHideTab::Undo()
    1152             : {
    1153           0 :     DoChange(!bShow);
    1154           0 : }
    1155             : 
    1156           0 : void ScUndoShowHideTab::Redo()
    1157             : {
    1158           0 :     DoChange(bShow);
    1159           0 : }
    1160             : 
    1161           0 : void ScUndoShowHideTab::Repeat(SfxRepeatTarget& rTarget)
    1162             : {
    1163           0 :     if (rTarget.ISA(ScTabViewTarget))
    1164           0 :         ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
    1165             :             Execute( bShow ? FID_TABLE_SHOW : FID_TABLE_HIDE,
    1166           0 :                                 SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
    1167           0 : }
    1168             : 
    1169           2 : bool ScUndoShowHideTab::CanRepeat(SfxRepeatTarget& rTarget) const
    1170             : {
    1171           2 :     return rTarget.ISA(ScTabViewTarget);
    1172             : }
    1173             : 
    1174           6 : OUString ScUndoShowHideTab::GetComment() const
    1175             : {
    1176             :     sal_uInt16 nId;
    1177           6 :     if (undoTabs.size() > 1)
    1178             :     {
    1179           0 :         nId = bShow ? STR_UNDO_SHOWTABS : STR_UNDO_HIDETABS;
    1180             :     }
    1181             :     else
    1182             :     {
    1183           6 :         nId = bShow ? STR_UNDO_SHOWTAB : STR_UNDO_HIDETAB;
    1184             :     }
    1185             : 
    1186           6 :     return ScGlobal::GetRscString( nId );
    1187             : }
    1188             : 
    1189             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1190           2 : ScUndoDocProtect::ScUndoDocProtect(ScDocShell* pShell, auto_ptr<ScDocProtection> pProtectSettings) :
    1191             :     ScSimpleUndo(pShell),
    1192           2 :     mpProtectSettings(pProtectSettings)
    1193             : {
    1194           2 : }
    1195             : SAL_WNODEPRECATED_DECLARATIONS_POP
    1196             : 
    1197           4 : ScUndoDocProtect::~ScUndoDocProtect()
    1198             : {
    1199           4 : }
    1200             : 
    1201           0 : void ScUndoDocProtect::DoProtect(bool bProtect)
    1202             : {
    1203           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1204             : 
    1205           0 :     if (bProtect)
    1206             :     {
    1207             :         // set protection.
    1208             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1209           0 :         auto_ptr<ScDocProtection> pCopy(new ScDocProtection(*mpProtectSettings));
    1210             :         SAL_WNODEPRECATED_DECLARATIONS_POP
    1211           0 :         pCopy->setProtected(true);
    1212           0 :         pDoc->SetDocProtection(pCopy.get());
    1213             :     }
    1214             :     else
    1215             :     {
    1216             :         // remove protection.
    1217           0 :         pDoc->SetDocProtection(NULL);
    1218             :     }
    1219             : 
    1220           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1221           0 :     if (pViewShell)
    1222             :     {
    1223           0 :         pViewShell->UpdateLayerLocks();
    1224           0 :         pViewShell->UpdateInputHandler(true);   // so that input can be immediately entered again
    1225             :     }
    1226             : 
    1227           0 :     pDocShell->PostPaintGridAll();
    1228           0 : }
    1229             : 
    1230           0 : void ScUndoDocProtect::Undo()
    1231             : {
    1232           0 :     BeginUndo();
    1233           0 :     DoProtect(!mpProtectSettings->isProtected());
    1234           0 :     EndUndo();
    1235           0 : }
    1236             : 
    1237           0 : void ScUndoDocProtect::Redo()
    1238             : {
    1239           0 :     BeginRedo();
    1240           0 :     DoProtect(mpProtectSettings->isProtected());
    1241           0 :     EndRedo();
    1242           0 : }
    1243             : 
    1244           0 : void ScUndoDocProtect::Repeat(SfxRepeatTarget& /* rTarget */)
    1245             : {
    1246             :     // makes no sense
    1247           0 : }
    1248             : 
    1249           2 : bool ScUndoDocProtect::CanRepeat(SfxRepeatTarget& /* rTarget */) const
    1250             : {
    1251           2 :     return false;       // makes no sense
    1252             : }
    1253             : 
    1254           4 : OUString ScUndoDocProtect::GetComment() const
    1255             : {
    1256           4 :     sal_uInt16 nId = mpProtectSettings->isProtected() ? STR_UNDO_PROTECT_DOC : STR_UNDO_UNPROTECT_DOC;
    1257           4 :     return ScGlobal::GetRscString( nId );
    1258             : }
    1259             : 
    1260             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1261           0 : ScUndoTabProtect::ScUndoTabProtect(ScDocShell* pShell, SCTAB nTab, auto_ptr<ScTableProtection> pProtectSettings) :
    1262             :     ScSimpleUndo(pShell),
    1263             :     mnTab(nTab),
    1264           0 :     mpProtectSettings(pProtectSettings)
    1265             : {
    1266           0 : }
    1267             : SAL_WNODEPRECATED_DECLARATIONS_POP
    1268             : 
    1269           0 : ScUndoTabProtect::~ScUndoTabProtect()
    1270             : {
    1271           0 : }
    1272             : 
    1273           0 : void ScUndoTabProtect::DoProtect(bool bProtect)
    1274             : {
    1275           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1276             : 
    1277           0 :     if (bProtect)
    1278             :     {
    1279             :         // set protection.
    1280             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1281           0 :         auto_ptr<ScTableProtection> pCopy(new ScTableProtection(*mpProtectSettings));
    1282             :         SAL_WNODEPRECATED_DECLARATIONS_POP
    1283           0 :         pCopy->setProtected(true);
    1284           0 :         pDoc->SetTabProtection(mnTab, pCopy.get());
    1285             :     }
    1286             :     else
    1287             :     {
    1288             :         // remove protection.
    1289           0 :         pDoc->SetTabProtection(mnTab, NULL);
    1290             :     }
    1291             : 
    1292           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1293           0 :     if (pViewShell)
    1294             :     {
    1295           0 :         pViewShell->UpdateLayerLocks();
    1296           0 :         pViewShell->UpdateInputHandler(true);   // so that input can be immediately entered again
    1297             :     }
    1298             : 
    1299           0 :     pDocShell->PostPaintGridAll();
    1300           0 : }
    1301             : 
    1302           0 : void ScUndoTabProtect::Undo()
    1303             : {
    1304           0 :     BeginUndo();
    1305           0 :     DoProtect(!mpProtectSettings->isProtected());
    1306           0 :     EndUndo();
    1307           0 : }
    1308             : 
    1309           0 : void ScUndoTabProtect::Redo()
    1310             : {
    1311           0 :     BeginRedo();
    1312           0 :     DoProtect(mpProtectSettings->isProtected());
    1313           0 :     EndRedo();
    1314           0 : }
    1315             : 
    1316           0 : void ScUndoTabProtect::Repeat(SfxRepeatTarget& /* rTarget */)
    1317             : {
    1318             :     // makes no sense
    1319           0 : }
    1320             : 
    1321           0 : bool ScUndoTabProtect::CanRepeat(SfxRepeatTarget& /* rTarget */) const
    1322             : {
    1323           0 :     return false;       // makes no sense
    1324             : }
    1325             : 
    1326           0 : OUString ScUndoTabProtect::GetComment() const
    1327             : {
    1328           0 :     sal_uInt16 nId = mpProtectSettings->isProtected() ? STR_UNDO_PROTECT_TAB : STR_UNDO_UNPROTECT_TAB;
    1329           0 :     return ScGlobal::GetRscString( nId );
    1330             : }
    1331             : 
    1332           2 : ScUndoPrintRange::ScUndoPrintRange( ScDocShell* pShell, SCTAB nNewTab,
    1333             :                                     ScPrintRangeSaver* pOld, ScPrintRangeSaver* pNew ) :
    1334             :     ScSimpleUndo( pShell ),
    1335             :     nTab( nNewTab ),
    1336             :     pOldRanges( pOld ),
    1337           2 :     pNewRanges( pNew )
    1338             : {
    1339           2 : }
    1340             : 
    1341           0 : ScUndoPrintRange::~ScUndoPrintRange()
    1342             : {
    1343           0 :     delete pOldRanges;
    1344           0 :     delete pNewRanges;
    1345           0 : }
    1346             : 
    1347           0 : void ScUndoPrintRange::DoChange(bool bUndo)
    1348             : {
    1349           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1350           0 :     if (bUndo)
    1351           0 :         pDoc->RestorePrintRanges( *pOldRanges );
    1352             :     else
    1353           0 :         pDoc->RestorePrintRanges( *pNewRanges );
    1354             : 
    1355           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1356           0 :     if (pViewShell)
    1357           0 :         pViewShell->SetTabNo( nTab );
    1358             : 
    1359           0 :     ScPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab ).UpdatePages();
    1360             : 
    1361           0 :     pDocShell->PostPaint( ScRange(0,0,nTab,MAXCOL,MAXROW,nTab), PAINT_GRID );
    1362           0 : }
    1363             : 
    1364           0 : void ScUndoPrintRange::Undo()
    1365             : {
    1366           0 :     BeginUndo();
    1367           0 :     DoChange( true );
    1368           0 :     EndUndo();
    1369           0 : }
    1370             : 
    1371           0 : void ScUndoPrintRange::Redo()
    1372             : {
    1373           0 :     BeginRedo();
    1374           0 :     DoChange( false );
    1375           0 :     EndRedo();
    1376           0 : }
    1377             : 
    1378           0 : void ScUndoPrintRange::Repeat(SfxRepeatTarget& /* rTarget */)
    1379             : {
    1380             :     // makes no sense
    1381           0 : }
    1382             : 
    1383           0 : bool ScUndoPrintRange::CanRepeat(SfxRepeatTarget& /* rTarget */) const
    1384             : {
    1385           0 :     return false;       // makes no sense
    1386             : }
    1387             : 
    1388           2 : OUString ScUndoPrintRange::GetComment() const
    1389             : {
    1390           2 :     return ScGlobal::GetRscString( STR_UNDO_PRINTRANGES );
    1391             : }
    1392             : 
    1393           0 : ScUndoScenarioFlags::ScUndoScenarioFlags( ScDocShell* pNewDocShell, SCTAB nT,
    1394             :                     const OUString& rON, const OUString& rNN, const OUString& rOC, const OUString& rNC,
    1395             :                     const Color& rOCol, const Color& rNCol, sal_uInt16 nOF, sal_uInt16 nNF ) :
    1396             :     ScSimpleUndo( pNewDocShell ),
    1397             :     nTab        ( nT ),
    1398             :     aOldName    ( rON ),
    1399             :     aNewName    ( rNN ),
    1400             :     aOldComment ( rOC ),
    1401             :     aNewComment ( rNC ),
    1402             :     aOldColor   ( rOCol ),
    1403             :     aNewColor   ( rNCol ),
    1404             :     nOldFlags   ( nOF ),
    1405           0 :     nNewFlags   ( nNF )
    1406             : {
    1407           0 : }
    1408             : 
    1409           0 : ScUndoScenarioFlags::~ScUndoScenarioFlags()
    1410             : {
    1411           0 : }
    1412             : 
    1413           0 : OUString ScUndoScenarioFlags::GetComment() const
    1414             : {
    1415           0 :     return ScGlobal::GetRscString( STR_UNDO_EDITSCENARIO );
    1416             : }
    1417             : 
    1418           0 : void ScUndoScenarioFlags::Undo()
    1419             : {
    1420           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1421             : 
    1422           0 :     pDoc->RenameTab( nTab, aOldName );
    1423           0 :     pDoc->SetScenarioData( nTab, aOldComment, aOldColor, nOldFlags );
    1424             : 
    1425           0 :     pDocShell->PostPaintGridAll();
    1426             :     // The sheet name might be used in a formula ...
    1427           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1428           0 :     if (pViewShell)
    1429           0 :         pViewShell->UpdateInputHandler();
    1430             : 
    1431           0 :     if ( aOldName != aNewName )
    1432           0 :         SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
    1433           0 : }
    1434             : 
    1435           0 : void ScUndoScenarioFlags::Redo()
    1436             : {
    1437           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1438             : 
    1439           0 :     pDoc->RenameTab( nTab, aNewName );
    1440           0 :     pDoc->SetScenarioData( nTab, aNewComment, aNewColor, nNewFlags );
    1441             : 
    1442           0 :     pDocShell->PostPaintGridAll();
    1443             :     // The sheet name might be used in a formula ...
    1444           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1445           0 :     if (pViewShell)
    1446           0 :         pViewShell->UpdateInputHandler();
    1447             : 
    1448           0 :     if ( aOldName != aNewName )
    1449           0 :         SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
    1450           0 : }
    1451             : 
    1452           0 : void ScUndoScenarioFlags::Repeat(SfxRepeatTarget& /* rTarget */)
    1453             : {
    1454             :     //  Repeat makes no sense
    1455           0 : }
    1456             : 
    1457           0 : bool ScUndoScenarioFlags::CanRepeat(SfxRepeatTarget& /* rTarget */) const
    1458             : {
    1459           0 :     return false;
    1460             : }
    1461             : 
    1462             : //      (move to different file?)
    1463           0 : ScUndoRenameObject::ScUndoRenameObject( ScDocShell* pNewDocShell, const OUString& rPN,
    1464             :                                         const OUString& rON, const OUString& rNN ) :
    1465             :     ScSimpleUndo( pNewDocShell ),
    1466             :     aPersistName( rPN ),
    1467             :     aOldName    ( rON ),
    1468           0 :     aNewName    ( rNN )
    1469             : {
    1470           0 : }
    1471             : 
    1472           0 : ScUndoRenameObject::~ScUndoRenameObject()
    1473             : {
    1474           0 : }
    1475             : 
    1476           0 : OUString ScUndoRenameObject::GetComment() const
    1477             : {
    1478             :     //  string resource shared with title for dialog
    1479           0 :     return OUString( ScResId(SCSTR_RENAMEOBJECT) );
    1480             : }
    1481             : 
    1482           0 : SdrObject* ScUndoRenameObject::GetObject()
    1483             : {
    1484           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1485           0 :     ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
    1486           0 :     if ( pDrawLayer )
    1487             :     {
    1488           0 :         sal_uInt16 nCount = pDrawLayer->GetPageCount();
    1489           0 :         for (sal_uInt16 nTab=0; nTab<nCount; nTab++)
    1490             :         {
    1491           0 :             SdrPage* pPage = pDrawLayer->GetPage(nTab);
    1492             :             OSL_ENSURE(pPage,"Page ?");
    1493             : 
    1494           0 :             SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
    1495           0 :             SdrObject* pObject = aIter.Next();
    1496           0 :             while (pObject)
    1497             :             {
    1498           0 :                 if ( pObject->GetObjIdentifier() == OBJ_OLE2 &&
    1499           0 :                         ((SdrOle2Obj*)pObject)->GetPersistName() == aPersistName )
    1500             :                 {
    1501           0 :                     return pObject;
    1502             :                 }
    1503             : 
    1504           0 :                 pObject = aIter.Next();
    1505             :             }
    1506           0 :         }
    1507             :     }
    1508             :     OSL_FAIL("Object not found");
    1509           0 :     return NULL;
    1510             : }
    1511             : 
    1512           0 : void ScUndoRenameObject::Undo()
    1513             : {
    1514           0 :     BeginUndo();
    1515           0 :     SdrObject* pObj = GetObject();
    1516           0 :     if ( pObj )
    1517           0 :         pObj->SetName( aOldName );
    1518           0 :     EndUndo();
    1519           0 : }
    1520             : 
    1521           0 : void ScUndoRenameObject::Redo()
    1522             : {
    1523           0 :     BeginRedo();
    1524           0 :     SdrObject* pObj = GetObject();
    1525           0 :     if ( pObj )
    1526           0 :         pObj->SetName( aNewName );
    1527           0 :     EndRedo();
    1528           0 : }
    1529             : 
    1530           0 : void ScUndoRenameObject::Repeat(SfxRepeatTarget& /* rTarget */)
    1531             : {
    1532           0 : }
    1533             : 
    1534           0 : bool ScUndoRenameObject::CanRepeat(SfxRepeatTarget& /* rTarget */) const
    1535             : {
    1536           0 :     return false;
    1537             : }
    1538             : 
    1539           4 : ScUndoLayoutRTL::ScUndoLayoutRTL( ScDocShell* pShell, SCTAB nNewTab, bool bNewRTL ) :
    1540             :     ScSimpleUndo( pShell ),
    1541             :     nTab( nNewTab ),
    1542           4 :     bRTL( bNewRTL )
    1543             : {
    1544           4 : }
    1545             : 
    1546           8 : ScUndoLayoutRTL::~ScUndoLayoutRTL()
    1547             : {
    1548           8 : }
    1549             : 
    1550           0 : void ScUndoLayoutRTL::DoChange( bool bNew )
    1551             : {
    1552           0 :     pDocShell->SetInUndo( true );
    1553             : 
    1554           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1555           0 :     pDoc->SetLayoutRTL( nTab, bNew );
    1556             : 
    1557           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1558           0 :     if (pViewShell)
    1559           0 :         pViewShell->SetTabNo(nTab,true);
    1560             : 
    1561           0 :     pDocShell->SetDocumentModified();
    1562             : 
    1563           0 :     pDocShell->SetInUndo( false );
    1564           0 : }
    1565             : 
    1566           0 : void ScUndoLayoutRTL::Undo()
    1567             : {
    1568           0 :     DoChange(!bRTL);
    1569           0 : }
    1570             : 
    1571           0 : void ScUndoLayoutRTL::Redo()
    1572             : {
    1573           0 :     DoChange(bRTL);
    1574           0 : }
    1575             : 
    1576           0 : void ScUndoLayoutRTL::Repeat(SfxRepeatTarget& rTarget)
    1577             : {
    1578           0 :     if (rTarget.ISA(ScTabViewTarget))
    1579           0 :         ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
    1580           0 :             Execute( FID_TAB_RTL, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
    1581           0 : }
    1582             : 
    1583           0 : bool ScUndoLayoutRTL::CanRepeat(SfxRepeatTarget& rTarget) const
    1584             : {
    1585           0 :     return rTarget.ISA(ScTabViewTarget);
    1586             : }
    1587             : 
    1588           4 : OUString ScUndoLayoutRTL::GetComment() const
    1589             : {
    1590           4 :     return ScGlobal::GetRscString( STR_UNDO_TAB_RTL );
    1591         102 : }
    1592             : 
    1593             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10