LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/undo - undotab.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 129 851 15.2 %
Date: 2013-07-09 Functions: 45 230 19.6 %
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             :                                   sal_Bool bApp,
      79             :                                   const String& 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          16 :         return ScGlobal::GetRscString( STR_UNDO_APPEND_TAB );
      99             :     else
     100          52 :         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( sal_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( sal_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          30 : bool ScUndoInsertTab::CanRepeat(SfxRepeatTarget& rTarget) const
     166             : {
     167          30 :     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( sal_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( sal_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          18 : ScUndoDeleteTab::ScUndoDeleteTab( ScDocShell* pNewDocShell, const vector<SCTAB> &aTab,
     266             :                                     ScDocument* pUndoDocument, ScRefUndoData* pRefData ) :
     267          18 :     ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST )
     268             : {
     269          18 :     theTabs.insert(theTabs.end(), aTab.begin(), aTab.end() );
     270          18 :     SetChangeTrack();
     271          18 : }
     272             : 
     273          54 : ScUndoDeleteTab::~ScUndoDeleteTab()
     274             : {
     275          18 :     theTabs.clear();
     276          36 : }
     277             : 
     278          22 : OUString ScUndoDeleteTab::GetComment() const
     279             : {
     280          22 :     return ScGlobal::GetRscString( STR_UNDO_DELETE_TAB );
     281             : }
     282             : 
     283          18 : void ScUndoDeleteTab::SetChangeTrack()
     284             : {
     285          18 :     ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
     286          18 :     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          18 :         nStartChangeAction = nEndChangeAction = 0;
     302          18 : }
     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           0 : void ScUndoDeleteTab::Undo()
     313             : {
     314           0 :     BeginUndo();
     315           0 :     unsigned int i=0;
     316           0 :     ScDocument* pDoc = pDocShell->GetDocument();
     317             : 
     318           0 :     sal_Bool bLink = false;
     319           0 :     OUString aName;
     320             : 
     321           0 :     for(i=0; i<theTabs.size(); ++i)
     322             :     {
     323           0 :         SCTAB nTab = theTabs[i];
     324           0 :         pRefUndoDoc->GetName( nTab, aName );
     325             : 
     326           0 :         bDrawIsInUndo = sal_True;
     327           0 :         sal_Bool bOk = pDoc->InsertTab( nTab, aName );
     328           0 :         bDrawIsInUndo = false;
     329           0 :         if (bOk)
     330             :         {
     331           0 :             pRefUndoDoc->CopyToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,false, pDoc );
     332             : 
     333           0 :             OUString aOldName;
     334           0 :             pRefUndoDoc->GetName( nTab, aOldName );
     335           0 :             pDoc->RenameTab( nTab, aOldName, false );
     336           0 :             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 = sal_True;
     342             :             }
     343             : 
     344           0 :             if ( pRefUndoDoc->IsScenario(nTab) )
     345             :             {
     346           0 :                 pDoc->SetScenario( nTab, sal_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           0 :             pDoc->SetVisible( nTab, pRefUndoDoc->IsVisible( nTab ) );
     356           0 :             pDoc->SetTabBgColor( nTab, pRefUndoDoc->GetTabBgColor(nTab) );
     357           0 :             pDoc->SetSheetEvents( nTab, pRefUndoDoc->GetSheetEvents( nTab ) );
     358           0 :             pDoc->SetLayoutRTL( nTab, pRefUndoDoc->IsLayoutRTL( nTab ) );
     359             : 
     360           0 :             if ( pRefUndoDoc->IsTabProtected( nTab ) )
     361           0 :                 pDoc->SetTabProtection(nTab, pRefUndoDoc->GetTabProtection(nTab));
     362             :         }
     363             :     }
     364           0 :     if (bLink)
     365             :     {
     366           0 :         pDocShell->UpdateLinks(); // update Link Manager
     367             :     }
     368             : 
     369           0 :     EndUndo();      // Draw-Undo has to be called before Broadcast!
     370             : 
     371           0 :     ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
     372           0 :     if ( pChangeTrack )
     373           0 :         pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
     374             : 
     375           0 :     for(i=0; i<theTabs.size(); ++i)
     376             :     {
     377           0 :         pDocShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, theTabs[i]) );
     378             :     }
     379           0 :     SfxApplication* pSfxApp = SFX_APP();                                // Navigator
     380           0 :     pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
     381           0 :     pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
     382           0 :     pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
     383             : 
     384           0 :     pDocShell->PostPaint(0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_ALL );  // incl. extras
     385             : 
     386             :     // not ShowTable due to SetTabNo(..., sal_True):
     387           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     388           0 :     if (pViewShell)
     389           0 :         pViewShell->SetTabNo( lcl_GetVisibleTabBefore( *pDoc, theTabs[0] ), true );
     390           0 : }
     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( sal_True );               //! BeginRedo
     400           0 :     bDrawIsInUndo = sal_True;
     401           0 :     pViewShell->DeleteTables( theTabs, false );
     402           0 :     bDrawIsInUndo = false;
     403           0 :     pDocShell->SetInUndo( sal_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(), sal_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 String& rOldName,
     428             :                                   const String& 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           2 : OUString ScUndoRenameTab::GetComment() const
     441             : {
     442           2 :     return ScGlobal::GetRscString( STR_UNDO_RENAME_TAB );
     443             : }
     444             : 
     445           2 : void ScUndoRenameTab::DoChange( SCTAB nTabP, const String& 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           0 : bool ScUndoRenameTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
     478             : {
     479           0 :     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( sal_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           0 :         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           0 :         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( sal_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, sal_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, sal_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 String& rN, const String& 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( sal_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, sal_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( sal_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, sal_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,sal_True);
     915             :         }
     916             :         else
     917             :         {
     918           0 :             pViewShell->SetTabNo(nTab-1,sal_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, sal_True,sal_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, sal_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, sal_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 String& rDoc ) :
    1040             :     ScSimpleUndo( pShell ),
    1041             :     aDocName( rDoc ),
    1042           0 :     nCount( 0 )
    1043             : {
    1044           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1045           0 :     SCTAB nTabCount = pDoc->GetTableCount();
    1046           0 :     pTabs     = new SCTAB[nTabCount];
    1047           0 :     pModes    = new sal_uInt8[nTabCount];
    1048           0 :     pTabNames = new String[nTabCount];
    1049             : 
    1050           0 :     for (SCTAB i=0; i<nTabCount; i++)
    1051             :     {
    1052           0 :         sal_uInt8 nMode = pDoc->GetLinkMode(i);
    1053           0 :         if (nMode)
    1054           0 :             if (pDoc->GetLinkDoc(i) == OUString(aDocName))
    1055             :             {
    1056           0 :                 if (!nCount)
    1057             :                 {
    1058           0 :                     aFltName = pDoc->GetLinkFlt(i);
    1059           0 :                     aOptions = pDoc->GetLinkOpt(i);
    1060           0 :                     nRefreshDelay = pDoc->GetLinkRefreshDelay(i);
    1061             :                 }
    1062             :                 else
    1063             :                 {
    1064             :                     OSL_ENSURE(OUString(aFltName) == pDoc->GetLinkFlt(i) &&
    1065             :                                OUString(aOptions) == pDoc->GetLinkOpt(i),
    1066             :                                     "different Filter for a Document?");
    1067             :                 }
    1068           0 :                 pTabs[nCount] = i;
    1069           0 :                 pModes[nCount] = nMode;
    1070           0 :                 pTabNames[nCount] = pDoc->GetLinkTab(i);
    1071           0 :                 ++nCount;
    1072             :             }
    1073             :     }
    1074           0 : }
    1075             : 
    1076           0 : ScUndoRemoveLink::~ScUndoRemoveLink()
    1077             : {
    1078           0 :     delete pTabs;
    1079           0 :     delete pModes;
    1080           0 :     delete[] pTabNames;
    1081           0 : }
    1082             : 
    1083           0 : OUString ScUndoRemoveLink::GetComment() const
    1084             : {
    1085           0 :     return ScGlobal::GetRscString( STR_UNDO_REMOVELINK );
    1086             : }
    1087             : 
    1088           0 : void ScUndoRemoveLink::DoChange( sal_Bool bLink ) const
    1089             : {
    1090           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1091           0 :     String aEmpty;
    1092           0 :     for (sal_uInt16 i=0; i<nCount; i++)
    1093           0 :         if (bLink)      // establish link
    1094           0 :             pDoc->SetLink( pTabs[i], pModes[i], aDocName, aFltName, aOptions, pTabNames[i], nRefreshDelay );
    1095             :         else            // remove link
    1096           0 :             pDoc->SetLink( pTabs[i], SC_LINK_NONE, aEmpty, aEmpty, aEmpty, aEmpty, 0 );
    1097           0 :     pDocShell->UpdateLinks();
    1098           0 : }
    1099             : 
    1100           0 : void ScUndoRemoveLink::Undo()
    1101             : {
    1102           0 :     DoChange( sal_True );
    1103           0 : }
    1104             : 
    1105           0 : void ScUndoRemoveLink::Redo()
    1106             : {
    1107           0 :     DoChange( false );
    1108           0 : }
    1109             : 
    1110           0 : void ScUndoRemoveLink::Repeat(SfxRepeatTarget& /* rTarget */)
    1111             : {
    1112             :     // makes no sense
    1113           0 : }
    1114             : 
    1115           0 : bool ScUndoRemoveLink::CanRepeat(SfxRepeatTarget& /* rTarget */) const
    1116             : {
    1117           0 :     return false;
    1118             : }
    1119             : 
    1120           2 : ScUndoShowHideTab::ScUndoShowHideTab( ScDocShell* pShell, const std::vector<SCTAB>& newUndoTabs, sal_Bool bNewShow ) :
    1121             :     ScSimpleUndo( pShell ),
    1122             :     undoTabs( newUndoTabs ),
    1123           2 :     bShow( bNewShow )
    1124             : {
    1125           2 : }
    1126             : 
    1127           4 : ScUndoShowHideTab::~ScUndoShowHideTab()
    1128             : {
    1129           4 : }
    1130             : 
    1131           0 : void ScUndoShowHideTab::DoChange( sal_Bool bShowP ) const
    1132             : {
    1133           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1134           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1135             : 
    1136             :     SCTAB nTab;
    1137             : 
    1138           0 :     for(std::vector<SCTAB>::const_iterator itr = undoTabs.begin(), itrEnd = undoTabs.end(); itr != itrEnd; ++itr)
    1139             :     {
    1140           0 :         nTab = *itr;
    1141           0 :         pDoc->SetVisible( nTab, bShowP );
    1142           0 :         if (pViewShell)
    1143           0 :             pViewShell->SetTabNo(nTab,sal_True);
    1144             :     }
    1145             : 
    1146           0 :     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
    1147           0 :     pDocShell->SetDocumentModified();
    1148           0 : }
    1149             : 
    1150           0 : void ScUndoShowHideTab::Undo()
    1151             : {
    1152           0 :     DoChange(!bShow);
    1153           0 : }
    1154             : 
    1155           0 : void ScUndoShowHideTab::Redo()
    1156             : {
    1157           0 :     DoChange(bShow);
    1158           0 : }
    1159             : 
    1160           0 : void ScUndoShowHideTab::Repeat(SfxRepeatTarget& rTarget)
    1161             : {
    1162           0 :     if (rTarget.ISA(ScTabViewTarget))
    1163           0 :         ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
    1164             :             Execute( bShow ? FID_TABLE_SHOW : FID_TABLE_HIDE,
    1165           0 :                                 SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
    1166           0 : }
    1167             : 
    1168           0 : bool ScUndoShowHideTab::CanRepeat(SfxRepeatTarget& rTarget) const
    1169             : {
    1170           0 :     return rTarget.ISA(ScTabViewTarget);
    1171             : }
    1172             : 
    1173           2 : OUString ScUndoShowHideTab::GetComment() const
    1174             : {
    1175             :     sal_uInt16 nId;
    1176           2 :     if (undoTabs.size() > 1)
    1177             :     {
    1178           0 :         nId = bShow ? STR_UNDO_SHOWTABS : STR_UNDO_HIDETABS;
    1179             :     }
    1180             :     else
    1181             :     {
    1182           2 :         nId = bShow ? STR_UNDO_SHOWTAB : STR_UNDO_HIDETAB;
    1183             :     }
    1184             : 
    1185           2 :     return ScGlobal::GetRscString( nId );
    1186             : }
    1187             : 
    1188             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1189           2 : ScUndoDocProtect::ScUndoDocProtect(ScDocShell* pShell, auto_ptr<ScDocProtection> pProtectSettings) :
    1190             :     ScSimpleUndo(pShell),
    1191           2 :     mpProtectSettings(pProtectSettings)
    1192             : {
    1193           2 : }
    1194             : SAL_WNODEPRECATED_DECLARATIONS_POP
    1195             : 
    1196           4 : ScUndoDocProtect::~ScUndoDocProtect()
    1197             : {
    1198           4 : }
    1199             : 
    1200           0 : void ScUndoDocProtect::DoProtect(bool bProtect)
    1201             : {
    1202           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1203             : 
    1204           0 :     if (bProtect)
    1205             :     {
    1206             :         // set protection.
    1207             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1208           0 :         auto_ptr<ScDocProtection> pCopy(new ScDocProtection(*mpProtectSettings));
    1209             :         SAL_WNODEPRECATED_DECLARATIONS_POP
    1210           0 :         pCopy->setProtected(true);
    1211           0 :         pDoc->SetDocProtection(pCopy.get());
    1212             :     }
    1213             :     else
    1214             :     {
    1215             :         // remove protection.
    1216           0 :         pDoc->SetDocProtection(NULL);
    1217             :     }
    1218             : 
    1219           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1220           0 :     if (pViewShell)
    1221             :     {
    1222           0 :         pViewShell->UpdateLayerLocks();
    1223           0 :         pViewShell->UpdateInputHandler(sal_True);   // so that input can be immediately entered again
    1224             :     }
    1225             : 
    1226           0 :     pDocShell->PostPaintGridAll();
    1227           0 : }
    1228             : 
    1229           0 : void ScUndoDocProtect::Undo()
    1230             : {
    1231           0 :     BeginUndo();
    1232           0 :     DoProtect(!mpProtectSettings->isProtected());
    1233           0 :     EndUndo();
    1234           0 : }
    1235             : 
    1236           0 : void ScUndoDocProtect::Redo()
    1237             : {
    1238           0 :     BeginRedo();
    1239           0 :     DoProtect(mpProtectSettings->isProtected());
    1240           0 :     EndRedo();
    1241           0 : }
    1242             : 
    1243           0 : void ScUndoDocProtect::Repeat(SfxRepeatTarget& /* rTarget */)
    1244             : {
    1245             :     // makes no sense
    1246           0 : }
    1247             : 
    1248           2 : bool ScUndoDocProtect::CanRepeat(SfxRepeatTarget& /* rTarget */) const
    1249             : {
    1250           2 :     return false;       // makes no sense
    1251             : }
    1252             : 
    1253           4 : OUString ScUndoDocProtect::GetComment() const
    1254             : {
    1255           4 :     sal_uInt16 nId = mpProtectSettings->isProtected() ? STR_UNDO_PROTECT_DOC : STR_UNDO_UNPROTECT_DOC;
    1256           4 :     return ScGlobal::GetRscString( nId );
    1257             : }
    1258             : 
    1259             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1260           0 : ScUndoTabProtect::ScUndoTabProtect(ScDocShell* pShell, SCTAB nTab, auto_ptr<ScTableProtection> pProtectSettings) :
    1261             :     ScSimpleUndo(pShell),
    1262             :     mnTab(nTab),
    1263           0 :     mpProtectSettings(pProtectSettings)
    1264             : {
    1265           0 : }
    1266             : SAL_WNODEPRECATED_DECLARATIONS_POP
    1267             : 
    1268           0 : ScUndoTabProtect::~ScUndoTabProtect()
    1269             : {
    1270           0 : }
    1271             : 
    1272           0 : void ScUndoTabProtect::DoProtect(bool bProtect)
    1273             : {
    1274           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1275             : 
    1276           0 :     if (bProtect)
    1277             :     {
    1278             :         // set protection.
    1279             :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1280           0 :         auto_ptr<ScTableProtection> pCopy(new ScTableProtection(*mpProtectSettings));
    1281             :         SAL_WNODEPRECATED_DECLARATIONS_POP
    1282           0 :         pCopy->setProtected(true);
    1283           0 :         pDoc->SetTabProtection(mnTab, pCopy.get());
    1284             :     }
    1285             :     else
    1286             :     {
    1287             :         // remove protection.
    1288           0 :         pDoc->SetTabProtection(mnTab, NULL);
    1289             :     }
    1290             : 
    1291           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1292           0 :     if (pViewShell)
    1293             :     {
    1294           0 :         pViewShell->UpdateLayerLocks();
    1295           0 :         pViewShell->UpdateInputHandler(sal_True);   // so that input can be immediately entered again
    1296             :     }
    1297             : 
    1298           0 :     pDocShell->PostPaintGridAll();
    1299           0 : }
    1300             : 
    1301           0 : void ScUndoTabProtect::Undo()
    1302             : {
    1303           0 :     BeginUndo();
    1304           0 :     DoProtect(!mpProtectSettings->isProtected());
    1305           0 :     EndUndo();
    1306           0 : }
    1307             : 
    1308           0 : void ScUndoTabProtect::Redo()
    1309             : {
    1310           0 :     BeginRedo();
    1311           0 :     DoProtect(mpProtectSettings->isProtected());
    1312           0 :     EndRedo();
    1313           0 : }
    1314             : 
    1315           0 : void ScUndoTabProtect::Repeat(SfxRepeatTarget& /* rTarget */)
    1316             : {
    1317             :     // makes no sense
    1318           0 : }
    1319             : 
    1320           0 : bool ScUndoTabProtect::CanRepeat(SfxRepeatTarget& /* rTarget */) const
    1321             : {
    1322           0 :     return false;       // makes no sense
    1323             : }
    1324             : 
    1325           0 : OUString ScUndoTabProtect::GetComment() const
    1326             : {
    1327           0 :     sal_uInt16 nId = mpProtectSettings->isProtected() ? STR_UNDO_PROTECT_TAB : STR_UNDO_UNPROTECT_TAB;
    1328           0 :     return ScGlobal::GetRscString( nId );
    1329             : }
    1330             : 
    1331           2 : ScUndoPrintRange::ScUndoPrintRange( ScDocShell* pShell, SCTAB nNewTab,
    1332             :                                     ScPrintRangeSaver* pOld, ScPrintRangeSaver* pNew ) :
    1333             :     ScSimpleUndo( pShell ),
    1334             :     nTab( nNewTab ),
    1335             :     pOldRanges( pOld ),
    1336           2 :     pNewRanges( pNew )
    1337             : {
    1338           2 : }
    1339             : 
    1340           0 : ScUndoPrintRange::~ScUndoPrintRange()
    1341             : {
    1342           0 :     delete pOldRanges;
    1343           0 :     delete pNewRanges;
    1344           0 : }
    1345             : 
    1346           0 : void ScUndoPrintRange::DoChange(sal_Bool bUndo)
    1347             : {
    1348           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1349           0 :     if (bUndo)
    1350           0 :         pDoc->RestorePrintRanges( *pOldRanges );
    1351             :     else
    1352           0 :         pDoc->RestorePrintRanges( *pNewRanges );
    1353             : 
    1354           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1355           0 :     if (pViewShell)
    1356           0 :         pViewShell->SetTabNo( nTab );
    1357             : 
    1358           0 :     ScPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab ).UpdatePages();
    1359             : 
    1360           0 :     pDocShell->PostPaint( ScRange(0,0,nTab,MAXCOL,MAXROW,nTab), PAINT_GRID );
    1361           0 : }
    1362             : 
    1363           0 : void ScUndoPrintRange::Undo()
    1364             : {
    1365           0 :     BeginUndo();
    1366           0 :     DoChange( sal_True );
    1367           0 :     EndUndo();
    1368           0 : }
    1369             : 
    1370           0 : void ScUndoPrintRange::Redo()
    1371             : {
    1372           0 :     BeginRedo();
    1373           0 :     DoChange( false );
    1374           0 :     EndRedo();
    1375           0 : }
    1376             : 
    1377           0 : void ScUndoPrintRange::Repeat(SfxRepeatTarget& /* rTarget */)
    1378             : {
    1379             :     // makes no sense
    1380           0 : }
    1381             : 
    1382           0 : bool ScUndoPrintRange::CanRepeat(SfxRepeatTarget& /* rTarget */) const
    1383             : {
    1384           0 :     return false;       // makes no sense
    1385             : }
    1386             : 
    1387           2 : OUString ScUndoPrintRange::GetComment() const
    1388             : {
    1389           2 :     return ScGlobal::GetRscString( STR_UNDO_PRINTRANGES );
    1390             : }
    1391             : 
    1392           0 : ScUndoScenarioFlags::ScUndoScenarioFlags( ScDocShell* pNewDocShell, SCTAB nT,
    1393             :                     const String& rON, const String& rNN, const String& rOC, const String& rNC,
    1394             :                     const Color& rOCol, const Color& rNCol, sal_uInt16 nOF, sal_uInt16 nNF ) :
    1395             :     ScSimpleUndo( pNewDocShell ),
    1396             :     nTab        ( nT ),
    1397             :     aOldName    ( rON ),
    1398             :     aNewName    ( rNN ),
    1399             :     aOldComment ( rOC ),
    1400             :     aNewComment ( rNC ),
    1401             :     aOldColor   ( rOCol ),
    1402             :     aNewColor   ( rNCol ),
    1403             :     nOldFlags   ( nOF ),
    1404           0 :     nNewFlags   ( nNF )
    1405             : {
    1406           0 : }
    1407             : 
    1408           0 : ScUndoScenarioFlags::~ScUndoScenarioFlags()
    1409             : {
    1410           0 : }
    1411             : 
    1412           0 : OUString ScUndoScenarioFlags::GetComment() const
    1413             : {
    1414           0 :     return ScGlobal::GetRscString( STR_UNDO_EDITSCENARIO );
    1415             : }
    1416             : 
    1417           0 : void ScUndoScenarioFlags::Undo()
    1418             : {
    1419           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1420             : 
    1421           0 :     pDoc->RenameTab( nTab, aOldName );
    1422           0 :     pDoc->SetScenarioData( nTab, aOldComment, aOldColor, nOldFlags );
    1423             : 
    1424           0 :     pDocShell->PostPaintGridAll();
    1425             :     // The sheet name might be used in a formula ...
    1426           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1427           0 :     if (pViewShell)
    1428           0 :         pViewShell->UpdateInputHandler();
    1429             : 
    1430           0 :     if ( aOldName != aNewName )
    1431           0 :         SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
    1432           0 : }
    1433             : 
    1434           0 : void ScUndoScenarioFlags::Redo()
    1435             : {
    1436           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1437             : 
    1438           0 :     pDoc->RenameTab( nTab, aNewName );
    1439           0 :     pDoc->SetScenarioData( nTab, aNewComment, aNewColor, nNewFlags );
    1440             : 
    1441           0 :     pDocShell->PostPaintGridAll();
    1442             :     // The sheet name might be used in a formula ...
    1443           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1444           0 :     if (pViewShell)
    1445           0 :         pViewShell->UpdateInputHandler();
    1446             : 
    1447           0 :     if ( aOldName != aNewName )
    1448           0 :         SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
    1449           0 : }
    1450             : 
    1451           0 : void ScUndoScenarioFlags::Repeat(SfxRepeatTarget& /* rTarget */)
    1452             : {
    1453             :     //  Repeat makes no sense
    1454           0 : }
    1455             : 
    1456           0 : bool ScUndoScenarioFlags::CanRepeat(SfxRepeatTarget& /* rTarget */) const
    1457             : {
    1458           0 :     return false;
    1459             : }
    1460             : 
    1461             : //      (move to different file?)
    1462           0 : ScUndoRenameObject::ScUndoRenameObject( ScDocShell* pNewDocShell, const String& rPN,
    1463             :                                         const String& rON, const String& rNN ) :
    1464             :     ScSimpleUndo( pNewDocShell ),
    1465             :     aPersistName( rPN ),
    1466             :     aOldName    ( rON ),
    1467           0 :     aNewName    ( rNN )
    1468             : {
    1469           0 : }
    1470             : 
    1471           0 : ScUndoRenameObject::~ScUndoRenameObject()
    1472             : {
    1473           0 : }
    1474             : 
    1475           0 : OUString ScUndoRenameObject::GetComment() const
    1476             : {
    1477             :     //  string resource shared with title for dialog
    1478           0 :     return String( ScResId(SCSTR_RENAMEOBJECT) );
    1479             : }
    1480             : 
    1481           0 : SdrObject* ScUndoRenameObject::GetObject()
    1482             : {
    1483           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1484           0 :     ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
    1485           0 :     if ( pDrawLayer )
    1486             :     {
    1487           0 :         sal_uInt16 nCount = pDrawLayer->GetPageCount();
    1488           0 :         for (sal_uInt16 nTab=0; nTab<nCount; nTab++)
    1489             :         {
    1490           0 :             SdrPage* pPage = pDrawLayer->GetPage(nTab);
    1491             :             OSL_ENSURE(pPage,"Page ?");
    1492             : 
    1493           0 :             SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
    1494           0 :             SdrObject* pObject = aIter.Next();
    1495           0 :             while (pObject)
    1496             :             {
    1497           0 :                 if ( pObject->GetObjIdentifier() == OBJ_OLE2 &&
    1498           0 :                         ((SdrOle2Obj*)pObject)->GetPersistName() == aPersistName )
    1499             :                 {
    1500           0 :                     return pObject;
    1501             :                 }
    1502             : 
    1503           0 :                 pObject = aIter.Next();
    1504             :             }
    1505           0 :         }
    1506             :     }
    1507             :     OSL_FAIL("Object not found");
    1508           0 :     return NULL;
    1509             : }
    1510             : 
    1511           0 : void ScUndoRenameObject::Undo()
    1512             : {
    1513           0 :     BeginUndo();
    1514           0 :     SdrObject* pObj = GetObject();
    1515           0 :     if ( pObj )
    1516           0 :         pObj->SetName( aOldName );
    1517           0 :     EndUndo();
    1518           0 : }
    1519             : 
    1520           0 : void ScUndoRenameObject::Redo()
    1521             : {
    1522           0 :     BeginRedo();
    1523           0 :     SdrObject* pObj = GetObject();
    1524           0 :     if ( pObj )
    1525           0 :         pObj->SetName( aNewName );
    1526           0 :     EndRedo();
    1527           0 : }
    1528             : 
    1529           0 : void ScUndoRenameObject::Repeat(SfxRepeatTarget& /* rTarget */)
    1530             : {
    1531           0 : }
    1532             : 
    1533           0 : bool ScUndoRenameObject::CanRepeat(SfxRepeatTarget& /* rTarget */) const
    1534             : {
    1535           0 :     return false;
    1536             : }
    1537             : 
    1538           4 : ScUndoLayoutRTL::ScUndoLayoutRTL( ScDocShell* pShell, SCTAB nNewTab, sal_Bool bNewRTL ) :
    1539             :     ScSimpleUndo( pShell ),
    1540             :     nTab( nNewTab ),
    1541           4 :     bRTL( bNewRTL )
    1542             : {
    1543           4 : }
    1544             : 
    1545           8 : ScUndoLayoutRTL::~ScUndoLayoutRTL()
    1546             : {
    1547           8 : }
    1548             : 
    1549           0 : void ScUndoLayoutRTL::DoChange( sal_Bool bNew )
    1550             : {
    1551           0 :     pDocShell->SetInUndo( sal_True );
    1552             : 
    1553           0 :     ScDocument* pDoc = pDocShell->GetDocument();
    1554           0 :     pDoc->SetLayoutRTL( nTab, bNew );
    1555             : 
    1556           0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
    1557           0 :     if (pViewShell)
    1558           0 :         pViewShell->SetTabNo(nTab,sal_True);
    1559             : 
    1560           0 :     pDocShell->SetDocumentModified();
    1561             : 
    1562           0 :     pDocShell->SetInUndo( false );
    1563           0 : }
    1564             : 
    1565           0 : void ScUndoLayoutRTL::Undo()
    1566             : {
    1567           0 :     DoChange(!bRTL);
    1568           0 : }
    1569             : 
    1570           0 : void ScUndoLayoutRTL::Redo()
    1571             : {
    1572           0 :     DoChange(bRTL);
    1573           0 : }
    1574             : 
    1575           0 : void ScUndoLayoutRTL::Repeat(SfxRepeatTarget& rTarget)
    1576             : {
    1577           0 :     if (rTarget.ISA(ScTabViewTarget))
    1578           0 :         ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
    1579           0 :             Execute( FID_TAB_RTL, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
    1580           0 : }
    1581             : 
    1582           4 : bool ScUndoLayoutRTL::CanRepeat(SfxRepeatTarget& rTarget) const
    1583             : {
    1584           4 :     return rTarget.ISA(ScTabViewTarget);
    1585             : }
    1586             : 
    1587          12 : OUString ScUndoLayoutRTL::GetComment() const
    1588             : {
    1589          12 :     return ScGlobal::GetRscString( STR_UNDO_TAB_RTL );
    1590          93 : }
    1591             : 
    1592             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10