1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: undotab.cxx,v $
10 * $Revision: 1.19.28.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 //------------------------------------------------------------------
38 // ?#define _MACRODLG_HXX
39 // ? #define _BIGINT_HXX
40 // ? #define _SVDXOUT_HXX
41 // ? #define _SVDATTR_HXX
42 // ? #define _SVDSURO_HXX
44 // INCLUDE ---------------------------------------------------------------
46 #include <sfx2/app.hxx>
47 #include <sfx2/bindings.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <svtools/smplhint.hxx>
51 #include "undotab.hxx"
52 #include "document.hxx"
54 #include "tabvwsh.hxx"
55 #include "globstr.hrc"
58 #include "undoolk.hxx"
60 #include "uiitems.hxx"
61 #include "prnsave.hxx"
62 #include "printfun.hxx"
63 #include "chgtrack.hxx"
64 #include "tabprotection.hxx"
66 // for ScUndoRenameObject - might me moved to another file later
67 #include <svx/svditer.hxx>
68 #include <svx/svdoole2.hxx>
69 #include <svx/svdpage.hxx>
70 #include "drwlayer.hxx"
71 #include "scresid.hxx"
73 // for set tab bg color
74 #include "viewdata.hxx"
76 extern BOOL bDrawIsInUndo
; //! irgendwo als Member !!!
78 using namespace com::sun::star
;
79 using ::com::sun::star::uno::Sequence
;
80 using ::std::auto_ptr
;
82 // STATIC DATA -----------------------------------------------------------
84 TYPEINIT1(ScUndoInsertTab
, SfxUndoAction
);
85 TYPEINIT1(ScUndoInsertTables
, SfxUndoAction
);
86 TYPEINIT1(ScUndoDeleteTab
, SfxUndoAction
);
87 TYPEINIT1(ScUndoRenameTab
, SfxUndoAction
);
88 TYPEINIT1(ScUndoMoveTab
, SfxUndoAction
);
89 TYPEINIT1(ScUndoCopyTab
, SfxUndoAction
);
90 TYPEINIT1(ScUndoMakeScenario
, SfxUndoAction
);
91 TYPEINIT1(ScUndoImportTab
, SfxUndoAction
);
92 TYPEINIT1(ScUndoRemoveLink
, SfxUndoAction
);
93 TYPEINIT1(ScUndoShowHideTab
, SfxUndoAction
);
94 TYPEINIT1(ScUndoPrintRange
, SfxUndoAction
);
95 TYPEINIT1(ScUndoScenarioFlags
, SfxUndoAction
);
96 TYPEINIT1(ScUndoRenameObject
, SfxUndoAction
);
97 TYPEINIT1(ScUndoLayoutRTL
, SfxUndoAction
);
98 //UNUSED2009-05 TYPEINIT1(ScUndoSetGrammar, SfxUndoAction);
99 TYPEINIT1(ScUndoSetTabBgColor
, SfxUndoAction
);
102 // -----------------------------------------------------------------------
107 ScUndoInsertTab::ScUndoInsertTab( ScDocShell
* pNewDocShell
,
110 const String
& rNewName
) :
111 ScSimpleUndo( pNewDocShell
),
112 sNewName( rNewName
),
117 pDrawUndo
= GetSdrUndoAction( pDocShell
->GetDocument() );
121 ScUndoInsertTab::~ScUndoInsertTab()
123 DeleteSdrUndoAction( pDrawUndo
);
126 String
ScUndoInsertTab::GetComment() const
129 return ScGlobal::GetRscString( STR_UNDO_APPEND_TAB
);
131 return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB
);
134 void ScUndoInsertTab::SetChangeTrack()
136 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
139 ScRange
aRange( 0, 0, nTab
, MAXCOL
, MAXROW
, nTab
);
140 pChangeTrack
->AppendInsert( aRange
);
141 nEndChangeAction
= pChangeTrack
->GetActionMax();
144 nEndChangeAction
= 0;
147 void ScUndoInsertTab::Undo()
149 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
150 pViewShell
->SetTabNo(nTab
);
152 pDocShell
->SetInUndo( TRUE
); //! BeginUndo
153 bDrawIsInUndo
= TRUE
;
154 pViewShell
->DeleteTable( nTab
, FALSE
);
155 bDrawIsInUndo
= FALSE
;
156 pDocShell
->SetInUndo( FALSE
); //! EndUndo
158 DoSdrUndoAction( pDrawUndo
, pDocShell
->GetDocument() );
160 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
162 pChangeTrack
->Undo( nEndChangeAction
, nEndChangeAction
);
164 // SetTabNo(...,TRUE) for all views to sync with drawing layer pages
165 pDocShell
->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB
) );
168 void ScUndoInsertTab::Redo()
170 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
172 RedoSdrUndoAction( pDrawUndo
); // Draw Redo first
174 pDocShell
->SetInUndo( TRUE
); //! BeginRedo
175 bDrawIsInUndo
= TRUE
;
177 pViewShell
->AppendTable( sNewName
, FALSE
);
180 pViewShell
->SetTabNo(nTab
);
181 pViewShell
->InsertTable( sNewName
, nTab
, FALSE
);
183 bDrawIsInUndo
= FALSE
;
184 pDocShell
->SetInUndo( FALSE
); //! EndRedo
189 void ScUndoInsertTab::Repeat(SfxRepeatTarget
& rTarget
)
191 if (rTarget
.ISA(ScTabViewTarget
))
192 ((ScTabViewTarget
&)rTarget
).GetViewShell()->GetViewData()->GetDispatcher().
193 Execute(FID_INS_TABLE
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
196 BOOL
ScUndoInsertTab::CanRepeat(SfxRepeatTarget
& rTarget
) const
198 return (rTarget
.ISA(ScTabViewTarget
));
201 // -----------------------------------------------------------------------
203 // Tabellen einfuegen
206 ScUndoInsertTables::ScUndoInsertTables( ScDocShell
* pNewDocShell
,
208 BOOL bApp
,SvStrings
*pNewNameList
) :
209 ScSimpleUndo( pNewDocShell
),
214 pNameList
= pNewNameList
;
215 pDrawUndo
= GetSdrUndoAction( pDocShell
->GetDocument() );
220 ScUndoInsertTables::~ScUndoInsertTables()
225 for(int i
=0;i
<pNameList
->Count();i
++)
227 pStr
=pNameList
->GetObject(sal::static_int_cast
<USHORT
>(i
));
230 pNameList
->Remove(0,pNameList
->Count());
233 DeleteSdrUndoAction( pDrawUndo
);
236 String
ScUndoInsertTables::GetComment() const
238 return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB
);
241 void ScUndoInsertTables::SetChangeTrack()
243 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
246 nStartChangeAction
= pChangeTrack
->GetActionMax() + 1;
247 nEndChangeAction
= 0;
248 ScRange
aRange( 0, 0, nTab
, MAXCOL
, MAXROW
, nTab
);
249 for( int i
= 0; i
< pNameList
->Count(); i
++ )
251 aRange
.aStart
.SetTab( sal::static_int_cast
<SCTAB
>( nTab
+ i
) );
252 aRange
.aEnd
.SetTab( sal::static_int_cast
<SCTAB
>( nTab
+ i
) );
253 pChangeTrack
->AppendInsert( aRange
);
254 nEndChangeAction
= pChangeTrack
->GetActionMax();
258 nStartChangeAction
= nEndChangeAction
= 0;
261 void ScUndoInsertTables::Undo()
263 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
264 pViewShell
->SetTabNo(nTab
);
266 pDocShell
->SetInUndo( TRUE
); //! BeginUndo
267 bDrawIsInUndo
= TRUE
;
270 for(int i
=0;i
<pNameList
->Count();i
++)
272 TheTabs
.Insert( sal::static_int_cast
<short>(nTab
+i
), TheTabs
.Count() );
275 pViewShell
->DeleteTables( TheTabs
, FALSE
);
276 TheTabs
.Remove(0,TheTabs
.Count());
278 bDrawIsInUndo
= FALSE
;
279 pDocShell
->SetInUndo( FALSE
); //! EndUndo
281 DoSdrUndoAction( pDrawUndo
, pDocShell
->GetDocument() );
283 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
285 pChangeTrack
->Undo( nStartChangeAction
, nEndChangeAction
);
287 // SetTabNo(...,TRUE) for all views to sync with drawing layer pages
288 pDocShell
->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB
) );
291 void ScUndoInsertTables::Redo()
293 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
295 RedoSdrUndoAction( pDrawUndo
); // Draw Redo first
297 pDocShell
->SetInUndo( TRUE
); //! BeginRedo
298 bDrawIsInUndo
= TRUE
;
299 pViewShell
->SetTabNo(nTab
);
300 pViewShell
->InsertTables( pNameList
, nTab
, static_cast<SCTAB
>(pNameList
->Count()),FALSE
);
302 bDrawIsInUndo
= FALSE
;
303 pDocShell
->SetInUndo( FALSE
); //! EndRedo
308 void ScUndoInsertTables::Repeat(SfxRepeatTarget
& rTarget
)
310 if (rTarget
.ISA(ScTabViewTarget
))
311 ((ScTabViewTarget
&)rTarget
).GetViewShell()->GetViewData()->GetDispatcher().
312 Execute(FID_INS_TABLE
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
315 BOOL
ScUndoInsertTables::CanRepeat(SfxRepeatTarget
& rTarget
) const
317 return (rTarget
.ISA(ScTabViewTarget
));
321 //----------------------------------------------------------------------------------
326 ScUndoDeleteTab::ScUndoDeleteTab( ScDocShell
* pNewDocShell
,const SvShorts
&aTab
, //SCTAB nNewTab,
327 ScDocument
* pUndoDocument
, ScRefUndoData
* pRefData
) :
328 ScMoveUndo( pNewDocShell
, pUndoDocument
, pRefData
, SC_UNDO_REFLAST
)
330 for(int i
=0;i
<aTab
.Count();i
++)
331 theTabs
.Insert(aTab
[sal::static_int_cast
<USHORT
>(i
)],theTabs
.Count());
336 ScUndoDeleteTab::~ScUndoDeleteTab()
338 theTabs
.Remove(0,theTabs
.Count());
341 String
ScUndoDeleteTab::GetComment() const
343 return ScGlobal::GetRscString( STR_UNDO_DELETE_TAB
);
346 void ScUndoDeleteTab::SetChangeTrack()
348 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
351 ULONG nTmpChangeAction
;
352 nStartChangeAction
= pChangeTrack
->GetActionMax() + 1;
353 nEndChangeAction
= 0;
354 ScRange
aRange( 0, 0, 0, MAXCOL
, MAXROW
, 0 );
355 for ( int i
= 0; i
< theTabs
.Count(); i
++ )
357 aRange
.aStart
.SetTab( theTabs
[sal::static_int_cast
<USHORT
>(i
)] );
358 aRange
.aEnd
.SetTab( theTabs
[sal::static_int_cast
<USHORT
>(i
)] );
359 pChangeTrack
->AppendDeleteRange( aRange
, pRefUndoDoc
,
360 nTmpChangeAction
, nEndChangeAction
, (short) i
);
364 nStartChangeAction
= nEndChangeAction
= 0;
367 SCTAB
lcl_GetVisibleTabBefore( ScDocument
& rDoc
, SCTAB nTab
)
369 while ( nTab
> 0 && !rDoc
.IsVisible( nTab
) )
375 void ScUndoDeleteTab::Undo()
379 ScDocument
* pDoc
= pDocShell
->GetDocument();
384 for(i
=0;i
<theTabs
.Count();i
++)
386 SCTAB nTab
= theTabs
[sal::static_int_cast
<USHORT
>(i
)];
387 pRefUndoDoc
->GetName( nTab
, aName
);
389 bDrawIsInUndo
= TRUE
;
390 BOOL bOk
= pDoc
->InsertTab( nTab
, aName
);
391 bDrawIsInUndo
= FALSE
;
394 // Ref-Undo passiert in EndUndo
395 // pUndoDoc->UndoToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,FALSE, pDoc );
396 pRefUndoDoc
->CopyToDocument(0,0,nTab
, MAXCOL
,MAXROW
,nTab
, IDF_ALL
,FALSE
, pDoc
);
399 pRefUndoDoc
->GetName( nTab
, aOldName
);
400 pDoc
->RenameTab( nTab
, aOldName
, FALSE
);
401 if (pRefUndoDoc
->IsLinked(nTab
))
403 pDoc
->SetLink( nTab
, pRefUndoDoc
->GetLinkMode(nTab
), pRefUndoDoc
->GetLinkDoc(nTab
),
404 pRefUndoDoc
->GetLinkFlt(nTab
), pRefUndoDoc
->GetLinkOpt(nTab
),
405 pRefUndoDoc
->GetLinkTab(nTab
), pRefUndoDoc
->GetLinkRefreshDelay(nTab
) );
409 if ( pRefUndoDoc
->IsScenario(nTab
) )
411 pDoc
->SetScenario( nTab
, TRUE
);
415 pRefUndoDoc
->GetScenarioData( nTab
, aComment
, aColor
, nScenFlags
);
416 pDoc
->SetScenarioData( nTab
, aComment
, aColor
, nScenFlags
);
417 BOOL bActive
= pRefUndoDoc
->IsActiveScenario( nTab
);
418 pDoc
->SetActiveScenario( nTab
, bActive
);
420 pDoc
->SetVisible( nTab
, pRefUndoDoc
->IsVisible( nTab
) );
422 if ( pRefUndoDoc
->IsTabProtected( nTab
) )
423 pDoc
->SetTabProtection(nTab
, pRefUndoDoc
->GetTabProtection(nTab
));
425 // Drawing-Layer passiert beim MoveUndo::EndUndo
426 // pDoc->TransferDrawPage(pRefUndoDoc, nTab,nTab);
431 pDocShell
->UpdateLinks(); // Link-Manager updaten
434 EndUndo(); // Draw-Undo muss vor dem Broadcast kommen!
436 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
438 pChangeTrack
->Undo( nStartChangeAction
, nEndChangeAction
);
440 for(i
=0;i
<theTabs
.Count();i
++)
442 pDocShell
->Broadcast( ScTablesHint( SC_TAB_INSERTED
, theTabs
[sal::static_int_cast
<USHORT
>(i
)]) );
444 SfxApplication
* pSfxApp
= SFX_APP(); // Navigator
445 pSfxApp
->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
446 pSfxApp
->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED
) );
447 pSfxApp
->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED
) );
449 pDocShell
->PostPaint(0,0,0, MAXCOL
,MAXROW
,MAXTAB
, PAINT_ALL
); // incl. Extras
451 // nicht ShowTable wegen SetTabNo(..., TRUE):
452 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
454 pViewShell
->SetTabNo( lcl_GetVisibleTabBefore( *pDoc
, theTabs
[0] ), TRUE
);
459 void ScUndoDeleteTab::Redo()
461 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
462 pViewShell
->SetTabNo( lcl_GetVisibleTabBefore( *pDocShell
->GetDocument(), theTabs
[0] ) );
464 RedoSdrUndoAction( pDrawUndo
); // Draw Redo first
466 pDocShell
->SetInUndo( TRUE
); //! BeginRedo
467 bDrawIsInUndo
= TRUE
;
468 pViewShell
->DeleteTables( theTabs
, FALSE
);
469 bDrawIsInUndo
= FALSE
;
470 pDocShell
->SetInUndo( TRUE
); //! EndRedo
474 // SetTabNo(...,TRUE) for all views to sync with drawing layer pages
475 pDocShell
->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB
) );
478 void ScUndoDeleteTab::Repeat(SfxRepeatTarget
& rTarget
)
480 if (rTarget
.ISA(ScTabViewTarget
))
482 ScTabViewShell
* pViewShell
= ((ScTabViewTarget
&)rTarget
).GetViewShell();
483 pViewShell
->DeleteTable( pViewShell
->GetViewData()->GetTabNo(), TRUE
);
487 BOOL
ScUndoDeleteTab::CanRepeat(SfxRepeatTarget
& rTarget
) const
489 return (rTarget
.ISA(ScTabViewTarget
));
493 //---------------------------------------------------------------------------------
495 // Tabelle umbenennen
498 ScUndoRenameTab::ScUndoRenameTab( ScDocShell
* pNewDocShell
,
500 const String
& rOldName
,
501 const String
& rNewName
) :
502 ScSimpleUndo( pNewDocShell
),
509 ScUndoRenameTab::~ScUndoRenameTab()
513 String
ScUndoRenameTab::GetComment() const
515 return ScGlobal::GetRscString( STR_UNDO_RENAME_TAB
);
518 void ScUndoRenameTab::DoChange( SCTAB nTabP
, const String
& rName
) const
520 ScDocument
* pDoc
= pDocShell
->GetDocument();
521 pDoc
->RenameTab( nTabP
, rName
);
523 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) ); // Navigator
525 pDocShell
->PostPaintGridAll();
526 pDocShell
->PostPaintExtras();
527 pDocShell
->PostDataChanged();
529 // Der Tabellenname koennte in einer Formel vorkommen...
530 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
532 pViewShell
->UpdateInputHandler();
535 void ScUndoRenameTab::Undo()
537 DoChange(nTab
, sOldName
);
540 void ScUndoRenameTab::Redo()
542 DoChange(nTab
, sNewName
);
545 void ScUndoRenameTab::Repeat(SfxRepeatTarget
& /* rTarget */)
547 // Repeat macht keinen Sinn
550 BOOL
ScUndoRenameTab::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
556 //----------------------------------------------------------------------------------
558 // Tabelle verschieben
561 ScUndoMoveTab::ScUndoMoveTab( ScDocShell
* pNewDocShell
,
562 const SvShorts
&aOldTab
,
563 const SvShorts
&aNewTab
) :
564 ScSimpleUndo( pNewDocShell
)
567 for(i
=0;i
<aOldTab
.Count();i
++)
568 theOldTabs
.Insert(aOldTab
[sal::static_int_cast
<USHORT
>(i
)],theOldTabs
.Count());
570 for(i
=0;i
<aNewTab
.Count();i
++)
571 theNewTabs
.Insert(aNewTab
[sal::static_int_cast
<USHORT
>(i
)],theNewTabs
.Count());
574 ScUndoMoveTab::~ScUndoMoveTab()
576 theNewTabs
.Remove(0,theNewTabs
.Count());
577 theOldTabs
.Remove(0,theOldTabs
.Count());
580 String
ScUndoMoveTab::GetComment() const
582 return ScGlobal::GetRscString( STR_UNDO_MOVE_TAB
);
585 void ScUndoMoveTab::DoChange( BOOL bUndo
) const
587 ScDocument
* pDoc
= pDocShell
->GetDocument();
588 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
592 for(int i
=theNewTabs
.Count()-1;i
>=0;i
--)
594 SCTAB nDestTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
595 SCTAB nOldTab
= theOldTabs
[sal::static_int_cast
<USHORT
>(i
)];
596 if (nDestTab
> MAXTAB
) // angehaengt ?
597 nDestTab
= pDoc
->GetTableCount() - 1;
599 pDoc
->MoveTab( nDestTab
, nOldTab
);
600 pViewShell
->GetViewData()->MoveTab( nDestTab
, nOldTab
);
601 pViewShell
->SetTabNo( nOldTab
, TRUE
);
606 for(int i
=0;i
<theNewTabs
.Count();i
++)
608 SCTAB nDestTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
609 SCTAB nNewTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
610 SCTAB nOldTab
= theOldTabs
[sal::static_int_cast
<USHORT
>(i
)];
611 if (nDestTab
> MAXTAB
) // angehaengt ?
612 nDestTab
= pDoc
->GetTableCount() - 1;
614 pDoc
->MoveTab( nOldTab
, nNewTab
);
615 pViewShell
->GetViewData()->MoveTab( nOldTab
, nNewTab
);
616 pViewShell
->SetTabNo( nDestTab
, TRUE
);
620 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) ); // Navigator
622 pDocShell
->PostPaintGridAll();
623 pDocShell
->PostPaintExtras();
624 pDocShell
->PostDataChanged();
627 void ScUndoMoveTab::Undo()
632 void ScUndoMoveTab::Redo()
637 void ScUndoMoveTab::Repeat(SfxRepeatTarget
& /* rTarget */)
642 BOOL
ScUndoMoveTab::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
648 //----------------------------------------------------------------------------------
653 ScUndoCopyTab::ScUndoCopyTab( ScDocShell
* pNewDocShell
,
654 const SvShorts
&aOldTab
,
655 const SvShorts
&aNewTab
) :
656 ScSimpleUndo( pNewDocShell
),
659 pDrawUndo
= GetSdrUndoAction( pDocShell
->GetDocument() );
662 for(i
=0;i
<aOldTab
.Count();i
++)
663 theOldTabs
.Insert(aOldTab
[sal::static_int_cast
<USHORT
>(i
)],theOldTabs
.Count());
665 for(i
=0;i
<aNewTab
.Count();i
++)
666 theNewTabs
.Insert(aNewTab
[sal::static_int_cast
<USHORT
>(i
)],theNewTabs
.Count());
669 ScUndoCopyTab::~ScUndoCopyTab()
671 DeleteSdrUndoAction( pDrawUndo
);
674 String
ScUndoCopyTab::GetComment() const
676 return ScGlobal::GetRscString( STR_UNDO_COPY_TAB
);
679 void ScUndoCopyTab::DoChange() const
681 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
684 pViewShell
->SetTabNo(theOldTabs
[0],TRUE
);
686 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) ); // Navigator
688 pDocShell
->PostPaintGridAll();
689 pDocShell
->PostPaintExtras();
690 pDocShell
->PostDataChanged();
693 void ScUndoCopyTab::Undo()
695 ScDocument
* pDoc
= pDocShell
->GetDocument();
697 DoSdrUndoAction( pDrawUndo
, pDoc
); // before the sheets are deleted
700 for(i
=theNewTabs
.Count()-1;i
>=0;i
--)
702 SCTAB nDestTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
703 if (nDestTab
> MAXTAB
) // append?
704 nDestTab
= pDoc
->GetTableCount() - 1;
706 bDrawIsInUndo
= TRUE
;
707 pDoc
->DeleteTab(nDestTab
);
708 bDrawIsInUndo
= FALSE
;
711 // ScTablesHint broadcasts after all sheets have been deleted,
712 // so sheets and draw pages are in sync!
714 for(i
=theNewTabs
.Count()-1;i
>=0;i
--)
716 SCTAB nDestTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
717 if (nDestTab
> MAXTAB
) // append?
718 nDestTab
= pDoc
->GetTableCount() - 1;
720 pDocShell
->Broadcast( ScTablesHint( SC_TAB_DELETED
, nDestTab
) );
726 void ScUndoCopyTab::Redo()
728 ScDocument
* pDoc
= pDocShell
->GetDocument();
729 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
732 for(int i
=0;i
<theNewTabs
.Count();i
++)
734 nDestTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
735 SCTAB nNewTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
736 SCTAB nOldTab
= theOldTabs
[sal::static_int_cast
<USHORT
>(i
)];
737 if (nDestTab
> MAXTAB
) // angehaengt ?
738 nDestTab
= pDoc
->GetTableCount() - 1;
740 bDrawIsInUndo
= TRUE
;
741 pDoc
->CopyTab( nOldTab
, nNewTab
);
742 bDrawIsInUndo
= FALSE
;
744 pViewShell
->GetViewData()->MoveTab( nOldTab
, nNewTab
);
746 SCTAB nAdjSource
= nOldTab
;
747 if ( nNewTab
<= nOldTab
)
748 ++nAdjSource
; // new position of source table after CopyTab
750 if ( pDoc
->IsScenario(nAdjSource
) )
752 pDoc
->SetScenario(nNewTab
, TRUE
);
756 pDoc
->GetScenarioData(nAdjSource
, aComment
, aColor
, nScenFlags
);
757 pDoc
->SetScenarioData(nNewTab
, aComment
, aColor
, nScenFlags
);
758 BOOL bActive
= pDoc
->IsActiveScenario(nAdjSource
);
759 pDoc
->SetActiveScenario(nNewTab
, bActive
);
760 BOOL bVisible
=pDoc
->IsVisible(nAdjSource
);
761 pDoc
->SetVisible(nNewTab
,bVisible
);
764 if ( pDoc
->IsTabProtected( nAdjSource
) )
765 pDoc
->CopyTabProtection(nAdjSource
, nNewTab
);
768 RedoSdrUndoAction( pDrawUndo
); // after the sheets are inserted
770 pViewShell
->SetTabNo( nDestTab
, TRUE
); // after draw-undo
776 void ScUndoCopyTab::Repeat(SfxRepeatTarget
& /* rTarget */)
781 BOOL
ScUndoCopyTab::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
786 //---------------------------------------------------------------------------------
791 ScUndoSetTabBgColor::ScUndoSetTabBgColor( ScDocShell
* pNewDocShell
,
793 const Color
& aOTabBgColor
,
794 const Color
& aNTabBgColor
) :
795 ScSimpleUndo( pNewDocShell
),
797 bIsMultipleUndo ( FALSE
),
798 aUndoSetTabBgColorInfoList ( NULL
)
800 aOldTabBgColor
= aOTabBgColor
;
801 aNewTabBgColor
= aNTabBgColor
;
804 ScUndoSetTabBgColor::ScUndoSetTabBgColor( ScDocShell
* pNewDocShell
,
805 ScUndoSetTabBgColorInfoList
* pUndoSetTabBgColorInfoList
) :
806 ScSimpleUndo( pNewDocShell
),
807 bIsMultipleUndo ( TRUE
)
809 aUndoSetTabBgColorInfoList
= pUndoSetTabBgColorInfoList
;
812 __EXPORT
ScUndoSetTabBgColor::~ScUndoSetTabBgColor()
816 String __EXPORT
ScUndoSetTabBgColor::GetComment() const
818 if (bIsMultipleUndo
&& aUndoSetTabBgColorInfoList
&& aUndoSetTabBgColorInfoList
->Count() > 1)
819 return ScGlobal::GetRscString( STR_UNDO_SET_MULTI_TAB_BG_COLOR
);
820 return ScGlobal::GetRscString( STR_UNDO_SET_TAB_BG_COLOR
);
823 void ScUndoSetTabBgColor::DoChange( SCTAB nTabP
, const Color
& rTabBgColor
) const
827 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
830 ScViewData
* pViewData
= pViewShell
->GetViewData();
833 pViewData
->SetTabBgColor( rTabBgColor
, nTabP
);
834 pDocShell
->PostPaintExtras();
835 pDocShell
->PostDataChanged();
836 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
837 pViewShell
->UpdateInputHandler();
842 void ScUndoSetTabBgColor::DoChange(BOOL bUndoType
) const
844 if (!bIsMultipleUndo
)
846 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
849 ScViewData
* pViewData
= pViewShell
->GetViewData();
852 ScUndoSetTabBgColorInfo
* aUndoSetTabBgColorInfo
=NULL
;
853 for (USHORT i
=0; i
< aUndoSetTabBgColorInfoList
->Count(); i
++)
855 aUndoSetTabBgColorInfo
= aUndoSetTabBgColorInfoList
->GetObject(i
);
856 pViewData
->SetTabBgColor(
857 bUndoType
? aUndoSetTabBgColorInfo
->aOldTabBgColor
: aUndoSetTabBgColorInfo
->aNewTabBgColor
,
858 aUndoSetTabBgColorInfo
->nTabId
);
860 pDocShell
->PostPaintExtras();
861 pDocShell
->PostDataChanged();
862 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
863 pViewShell
->UpdateInputHandler();
868 void __EXPORT
ScUndoSetTabBgColor::Undo()
870 if ( bIsMultipleUndo
)
873 DoChange(nTab
, aOldTabBgColor
);
876 void __EXPORT
ScUndoSetTabBgColor::Redo()
878 if ( bIsMultipleUndo
)
881 DoChange(nTab
, aNewTabBgColor
);
884 void __EXPORT
ScUndoSetTabBgColor::Repeat(SfxRepeatTarget
& /* rTarget */)
889 BOOL __EXPORT
ScUndoSetTabBgColor::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
894 // -----------------------------------------------------------------------
899 ScUndoMakeScenario::ScUndoMakeScenario( ScDocShell
* pNewDocShell
,
900 SCTAB nSrc
, SCTAB nDest
,
901 const String
& rN
, const String
& rC
,
902 const Color
& rCol
, USHORT nF
,
903 const ScMarkData
& rMark
) :
904 ScSimpleUndo( pNewDocShell
),
914 pDrawUndo
= GetSdrUndoAction( pDocShell
->GetDocument() );
917 ScUndoMakeScenario::~ScUndoMakeScenario()
919 DeleteSdrUndoAction( pDrawUndo
);
922 String
ScUndoMakeScenario::GetComment() const
924 return ScGlobal::GetRscString( STR_UNDO_MAKESCENARIO
);
927 void ScUndoMakeScenario::Undo()
929 ScDocument
* pDoc
= pDocShell
->GetDocument();
931 pDocShell
->SetInUndo( TRUE
);
932 bDrawIsInUndo
= TRUE
;
933 pDoc
->DeleteTab( nDestTab
);
934 bDrawIsInUndo
= FALSE
;
935 pDocShell
->SetInUndo( FALSE
);
937 DoSdrUndoAction( pDrawUndo
, pDoc
);
939 pDocShell
->PostPaint(0,0,nDestTab
,MAXCOL
,MAXROW
,MAXTAB
, PAINT_ALL
);
940 pDocShell
->PostDataChanged();
942 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
944 pViewShell
->SetTabNo( nSrcTab
, TRUE
);
946 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
948 // SetTabNo(...,TRUE) for all views to sync with drawing layer pages
949 pDocShell
->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB
) );
952 void ScUndoMakeScenario::Redo()
954 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
956 pViewShell
->SetMarkData( aMarkData
);
958 RedoSdrUndoAction( pDrawUndo
); // Draw Redo first
960 pDocShell
->SetInUndo( TRUE
);
961 bDrawIsInUndo
= TRUE
;
963 pDocShell
->MakeScenario( nSrcTab
, aName
, aComment
, aColor
, nFlags
, aMarkData
, FALSE
);
965 bDrawIsInUndo
= FALSE
;
966 pDocShell
->SetInUndo( FALSE
);
969 pViewShell
->SetTabNo( nDestTab
, TRUE
);
971 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
974 void ScUndoMakeScenario::Repeat(SfxRepeatTarget
& rTarget
)
976 if (rTarget
.ISA(ScTabViewTarget
))
978 ((ScTabViewTarget
&)rTarget
).GetViewShell()->MakeScenario( aName
, aComment
, aColor
, nFlags
);
982 BOOL
ScUndoMakeScenario::CanRepeat(SfxRepeatTarget
& rTarget
) const
984 return (rTarget
.ISA(ScTabViewTarget
));
988 // -----------------------------------------------------------------------
993 ScUndoImportTab::ScUndoImportTab( ScDocShell
* pShell
,
994 SCTAB nNewTab
, SCTAB nNewCount
, BOOL bNewLink
) :
995 ScSimpleUndo( pShell
),
1002 pDrawUndo
= GetSdrUndoAction( pDocShell
->GetDocument() );
1005 ScUndoImportTab::~ScUndoImportTab()
1008 DeleteSdrUndoAction( pDrawUndo
);
1011 String
ScUndoImportTab::GetComment() const
1013 return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB
);
1016 void ScUndoImportTab::DoChange() const
1018 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1019 ScDocument
* pDoc
= pDocShell
->GetDocument();
1020 SCTAB nTabCount
= pDoc
->GetTableCount();
1025 pViewShell
->SetTabNo(nTab
,TRUE
);
1029 pViewShell
->SetTabNo(nTab
-1,TRUE
);
1033 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) ); // Navigator
1034 pDocShell
->PostPaint( 0,0,0, MAXCOL
,MAXROW
,MAXTAB
,
1035 PAINT_GRID
| PAINT_TOP
| PAINT_LEFT
| PAINT_EXTRAS
);
1038 void ScUndoImportTab::Undo()
1040 //! eingefuegte Bereichsnamen etc.
1043 ScDocument
* pDoc
= pDocShell
->GetDocument();
1044 BOOL bMakeRedo
= !pRedoDoc
;
1047 pRedoDoc
= new ScDocument( SCDOCMODE_UNDO
);
1048 pRedoDoc
->InitUndo( pDoc
, nTab
,nTab
+nCount
-1, TRUE
,TRUE
);
1051 for (i
=0; i
<nCount
; i
++)
1053 SCTAB nTabPos
=nTab
+i
;
1055 pDoc
->CopyToDocument(0,0,nTabPos
, MAXCOL
,MAXROW
,nTabPos
, IDF_ALL
,FALSE
, pRedoDoc
);
1056 pDoc
->GetName( nTabPos
, aOldName
);
1057 pRedoDoc
->RenameTab( nTabPos
, aOldName
, FALSE
);
1059 if ( pDoc
->IsScenario(nTabPos
) )
1061 pRedoDoc
->SetScenario(nTabPos
, TRUE
);
1065 pDoc
->GetScenarioData(nTabPos
, aComment
, aColor
, nScenFlags
);
1066 pRedoDoc
->SetScenarioData(nTabPos
, aComment
, aColor
, nScenFlags
);
1067 BOOL bActive
= pDoc
->IsActiveScenario(nTabPos
);
1068 pRedoDoc
->SetActiveScenario(nTabPos
, bActive
);
1069 BOOL bVisible
=pDoc
->IsVisible(nTabPos
);
1070 pRedoDoc
->SetVisible(nTabPos
,bVisible
);
1073 if ( pDoc
->IsTabProtected( nTabPos
) )
1074 pRedoDoc
->SetTabProtection(nTabPos
, pDoc
->GetTabProtection(nTabPos
));
1079 DoSdrUndoAction( pDrawUndo
, pDoc
); // before the sheets are deleted
1081 bDrawIsInUndo
= TRUE
;
1082 for (i
=0; i
<nCount
; i
++)
1083 pDoc
->DeleteTab( nTab
);
1084 bDrawIsInUndo
= FALSE
;
1089 void ScUndoImportTab::Redo()
1093 DBG_ERROR("wo ist mein Redo-Document?");
1097 ScDocument
* pDoc
= pDocShell
->GetDocument();
1100 for (i
=0; i
<nCount
; i
++) // first insert all sheets (#63304#)
1102 SCTAB nTabPos
=nTab
+i
;
1103 pRedoDoc
->GetName(nTabPos
,aName
);
1104 bDrawIsInUndo
= TRUE
;
1105 pDoc
->InsertTab(nTabPos
,aName
);
1106 bDrawIsInUndo
= FALSE
;
1108 for (i
=0; i
<nCount
; i
++) // then copy into inserted sheets
1110 SCTAB nTabPos
=nTab
+i
;
1111 pRedoDoc
->CopyToDocument(0,0,nTabPos
, MAXCOL
,MAXROW
,nTabPos
, IDF_ALL
,FALSE
, pDoc
);
1113 if ( pRedoDoc
->IsScenario(nTabPos
) )
1115 pDoc
->SetScenario(nTabPos
, TRUE
);
1119 pRedoDoc
->GetScenarioData(nTabPos
, aComment
, aColor
, nScenFlags
);
1120 pDoc
->SetScenarioData(nTabPos
, aComment
, aColor
, nScenFlags
);
1121 BOOL bActive
= pRedoDoc
->IsActiveScenario(nTabPos
);
1122 pDoc
->SetActiveScenario(nTabPos
, bActive
);
1123 BOOL bVisible
=pRedoDoc
->IsVisible(nTabPos
);
1124 pDoc
->SetVisible(nTabPos
,bVisible
);
1127 if ( pRedoDoc
->IsTabProtected( nTabPos
) )
1128 pDoc
->SetTabProtection(nTabPos
, pRedoDoc
->GetTabProtection(nTabPos
));
1131 RedoSdrUndoAction( pDrawUndo
); // after the sheets are inserted
1136 void ScUndoImportTab::Repeat(SfxRepeatTarget
& rTarget
)
1138 if (rTarget
.ISA(ScTabViewTarget
))
1139 ((ScTabViewTarget
&)rTarget
).GetViewShell()->GetViewData()->GetDispatcher().
1140 Execute(FID_INS_TABLE
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
1143 BOOL
ScUndoImportTab::CanRepeat(SfxRepeatTarget
& rTarget
) const
1145 return (rTarget
.ISA(ScTabViewTarget
));
1149 // -----------------------------------------------------------------------
1151 // Tabellen-Verknuepfung aufheben
1154 ScUndoRemoveLink::ScUndoRemoveLink( ScDocShell
* pShell
, const String
& rDoc
) :
1155 ScSimpleUndo( pShell
),
1159 ScDocument
* pDoc
= pDocShell
->GetDocument();
1160 SCTAB nTabCount
= pDoc
->GetTableCount();
1161 pTabs
= new SCTAB
[nTabCount
];
1162 pModes
= new BYTE
[nTabCount
];
1163 pTabNames
= new String
[nTabCount
];
1165 for (SCTAB i
=0; i
<nTabCount
; i
++)
1167 BYTE nMode
= pDoc
->GetLinkMode(i
);
1169 if (pDoc
->GetLinkDoc(i
) == aDocName
)
1173 aFltName
= pDoc
->GetLinkFlt(i
);
1174 aOptions
= pDoc
->GetLinkOpt(i
);
1175 nRefreshDelay
= pDoc
->GetLinkRefreshDelay(i
);
1179 DBG_ASSERT(aFltName
== pDoc
->GetLinkFlt(i
) &&
1180 aOptions
== pDoc
->GetLinkOpt(i
),
1181 "verschiedene Filter fuer ein Dokument?");
1184 pModes
[nCount
] = nMode
;
1185 pTabNames
[nCount
] = pDoc
->GetLinkTab(i
);
1191 ScUndoRemoveLink::~ScUndoRemoveLink()
1198 String
ScUndoRemoveLink::GetComment() const
1200 return ScGlobal::GetRscString( STR_UNDO_REMOVELINK
);
1203 void ScUndoRemoveLink::DoChange( BOOL bLink
) const
1205 ScDocument
* pDoc
= pDocShell
->GetDocument();
1207 for (USHORT i
=0; i
<nCount
; i
++)
1208 if (bLink
) // establish link
1209 pDoc
->SetLink( pTabs
[i
], pModes
[i
], aDocName
, aFltName
, aOptions
, pTabNames
[i
], nRefreshDelay
);
1211 pDoc
->SetLink( pTabs
[i
], SC_LINK_NONE
, aEmpty
, aEmpty
, aEmpty
, aEmpty
, 0 );
1212 pDocShell
->UpdateLinks();
1215 void ScUndoRemoveLink::Undo()
1220 void ScUndoRemoveLink::Redo()
1225 void ScUndoRemoveLink::Repeat(SfxRepeatTarget
& /* rTarget */)
1230 BOOL
ScUndoRemoveLink::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1236 // -----------------------------------------------------------------------
1238 // Tabellen ein-/ausblenden
1241 ScUndoShowHideTab::ScUndoShowHideTab( ScDocShell
* pShell
, SCTAB nNewTab
, BOOL bNewShow
) :
1242 ScSimpleUndo( pShell
),
1248 ScUndoShowHideTab::~ScUndoShowHideTab()
1252 void ScUndoShowHideTab::DoChange( BOOL bShowP
) const
1254 ScDocument
* pDoc
= pDocShell
->GetDocument();
1255 pDoc
->SetVisible( nTab
, bShowP
);
1257 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1259 pViewShell
->SetTabNo(nTab
,TRUE
);
1261 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
1262 pDocShell
->SetDocumentModified();
1265 void ScUndoShowHideTab::Undo()
1270 void ScUndoShowHideTab::Redo()
1275 void ScUndoShowHideTab::Repeat(SfxRepeatTarget
& rTarget
)
1277 if (rTarget
.ISA(ScTabViewTarget
))
1278 ((ScTabViewTarget
&)rTarget
).GetViewShell()->GetViewData()->GetDispatcher().
1279 Execute( bShow
? FID_TABLE_SHOW
: FID_TABLE_HIDE
,
1280 SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
1283 BOOL
ScUndoShowHideTab::CanRepeat(SfxRepeatTarget
& rTarget
) const
1285 return (rTarget
.ISA(ScTabViewTarget
));
1288 String
ScUndoShowHideTab::GetComment() const
1290 USHORT nId
= bShow
? STR_UNDO_SHOWTAB
: STR_UNDO_HIDETAB
;
1291 return ScGlobal::GetRscString( nId
);
1294 // ============================================================================
1296 ScUndoDocProtect::ScUndoDocProtect(ScDocShell
* pShell
, auto_ptr
<ScDocProtection
> pProtectSettings
) :
1297 ScSimpleUndo(pShell
),
1298 mpProtectSettings(pProtectSettings
)
1302 ScUndoDocProtect::~ScUndoDocProtect()
1306 void ScUndoDocProtect::DoProtect(bool bProtect
)
1308 ScDocument
* pDoc
= pDocShell
->GetDocument();
1313 auto_ptr
<ScDocProtection
> pCopy(new ScDocProtection(*mpProtectSettings
));
1314 pCopy
->setProtected(true);
1315 pDoc
->SetDocProtection(pCopy
.get());
1319 // remove protection.
1320 pDoc
->SetDocProtection(NULL
);
1323 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1326 pViewShell
->UpdateLayerLocks();
1327 pViewShell
->UpdateInputHandler(TRUE
); // damit sofort wieder eingegeben werden kann
1330 pDocShell
->PostPaintGridAll();
1333 void ScUndoDocProtect::Undo()
1336 DoProtect(!mpProtectSettings
->isProtected());
1340 void ScUndoDocProtect::Redo()
1343 DoProtect(mpProtectSettings
->isProtected());
1347 void ScUndoDocProtect::Repeat(SfxRepeatTarget
& /* rTarget */)
1352 BOOL
ScUndoDocProtect::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1354 return FALSE
; // gippsnich
1357 String
ScUndoDocProtect::GetComment() const
1359 USHORT nId
= mpProtectSettings
->isProtected() ? STR_UNDO_PROTECT_DOC
: STR_UNDO_UNPROTECT_DOC
;
1360 return ScGlobal::GetRscString( nId
);
1363 // ============================================================================
1365 ScUndoTabProtect::ScUndoTabProtect(ScDocShell
* pShell
, SCTAB nTab
, auto_ptr
<ScTableProtection
> pProtectSettings
) :
1366 ScSimpleUndo(pShell
),
1368 mpProtectSettings(pProtectSettings
)
1372 ScUndoTabProtect::~ScUndoTabProtect()
1376 void ScUndoTabProtect::DoProtect(bool bProtect
)
1378 ScDocument
* pDoc
= pDocShell
->GetDocument();
1383 auto_ptr
<ScTableProtection
> pCopy(new ScTableProtection(*mpProtectSettings
));
1384 pCopy
->setProtected(true);
1385 pDoc
->SetTabProtection(mnTab
, pCopy
.get());
1389 // remove protection.
1390 pDoc
->SetTabProtection(mnTab
, NULL
);
1393 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1396 pViewShell
->UpdateLayerLocks();
1397 pViewShell
->UpdateInputHandler(TRUE
); // damit sofort wieder eingegeben werden kann
1400 pDocShell
->PostPaintGridAll();
1403 void ScUndoTabProtect::Undo()
1406 DoProtect(!mpProtectSettings
->isProtected());
1410 void ScUndoTabProtect::Redo()
1413 DoProtect(mpProtectSettings
->isProtected());
1417 void ScUndoTabProtect::Repeat(SfxRepeatTarget
& /* rTarget */)
1422 BOOL
ScUndoTabProtect::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1424 return FALSE
; // gippsnich
1427 String
ScUndoTabProtect::GetComment() const
1429 USHORT nId
= mpProtectSettings
->isProtected() ? STR_UNDO_PROTECT_TAB
: STR_UNDO_UNPROTECT_TAB
;
1430 return ScGlobal::GetRscString( nId
);
1433 // -----------------------------------------------------------------------
1435 // Druck-/Wiederholungsbereiche aendern
1438 ScUndoPrintRange::ScUndoPrintRange( ScDocShell
* pShell
, SCTAB nNewTab
,
1439 ScPrintRangeSaver
* pOld
, ScPrintRangeSaver
* pNew
) :
1440 ScSimpleUndo( pShell
),
1447 ScUndoPrintRange::~ScUndoPrintRange()
1453 void ScUndoPrintRange::DoChange(BOOL bUndo
)
1455 ScDocument
* pDoc
= pDocShell
->GetDocument();
1457 pDoc
->RestorePrintRanges( *pOldRanges
);
1459 pDoc
->RestorePrintRanges( *pNewRanges
);
1461 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1463 pViewShell
->SetTabNo( nTab
);
1465 ScPrintFunc( pDocShell
, pDocShell
->GetPrinter(), nTab
).UpdatePages();
1467 pDocShell
->PostPaint( ScRange(0,0,nTab
,MAXCOL
,MAXROW
,nTab
), PAINT_GRID
);
1470 void ScUndoPrintRange::Undo()
1477 void ScUndoPrintRange::Redo()
1484 void ScUndoPrintRange::Repeat(SfxRepeatTarget
& /* rTarget */)
1489 BOOL
ScUndoPrintRange::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1491 return FALSE
; // gippsnich
1494 String
ScUndoPrintRange::GetComment() const
1496 return ScGlobal::GetRscString( STR_UNDO_PRINTRANGES
);
1500 //------------------------------------------------------------------------
1502 //---------------------------------------------------------------------------------
1507 ScUndoScenarioFlags::ScUndoScenarioFlags( ScDocShell
* pNewDocShell
, SCTAB nT
,
1508 const String
& rON
, const String
& rNN
, const String
& rOC
, const String
& rNC
,
1509 const Color
& rOCol
, const Color
& rNCol
, USHORT nOF
, USHORT nNF
) :
1510 ScSimpleUndo( pNewDocShell
),
1514 aOldComment ( rOC
),
1515 aNewComment ( rNC
),
1516 aOldColor ( rOCol
),
1517 aNewColor ( rNCol
),
1523 ScUndoScenarioFlags::~ScUndoScenarioFlags()
1527 String
ScUndoScenarioFlags::GetComment() const
1529 return ScGlobal::GetRscString( STR_UNDO_EDITSCENARIO
);
1532 void ScUndoScenarioFlags::Undo()
1534 ScDocument
* pDoc
= pDocShell
->GetDocument();
1536 pDoc
->RenameTab( nTab
, aOldName
);
1537 pDoc
->SetScenarioData( nTab
, aOldComment
, aOldColor
, nOldFlags
);
1539 pDocShell
->PostPaintGridAll();
1540 // Der Tabellenname koennte in einer Formel vorkommen...
1541 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1543 pViewShell
->UpdateInputHandler();
1545 if ( aOldName
!= aNewName
)
1546 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
1549 void ScUndoScenarioFlags::Redo()
1551 ScDocument
* pDoc
= pDocShell
->GetDocument();
1553 pDoc
->RenameTab( nTab
, aNewName
);
1554 pDoc
->SetScenarioData( nTab
, aNewComment
, aNewColor
, nNewFlags
);
1556 pDocShell
->PostPaintGridAll();
1557 // Der Tabellenname koennte in einer Formel vorkommen...
1558 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1560 pViewShell
->UpdateInputHandler();
1562 if ( aOldName
!= aNewName
)
1563 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
1566 void ScUndoScenarioFlags::Repeat(SfxRepeatTarget
& /* rTarget */)
1568 // Repeat macht keinen Sinn
1571 BOOL
ScUndoScenarioFlags::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1577 //---------------------------------------------------------------------------------
1580 // (move to different file?)
1583 ScUndoRenameObject::ScUndoRenameObject( ScDocShell
* pNewDocShell
, const String
& rPN
,
1584 const String
& rON
, const String
& rNN
) :
1585 ScSimpleUndo( pNewDocShell
),
1586 aPersistName( rPN
),
1592 ScUndoRenameObject::~ScUndoRenameObject()
1596 String
ScUndoRenameObject::GetComment() const
1598 // string resource shared with title for dialog
1599 return String( ScResId(SCSTR_RENAMEOBJECT
) );
1602 SdrObject
* ScUndoRenameObject::GetObject()
1604 ScDocument
* pDoc
= pDocShell
->GetDocument();
1605 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
1608 USHORT nCount
= pDrawLayer
->GetPageCount();
1609 for (USHORT nTab
=0; nTab
<nCount
; nTab
++)
1611 SdrPage
* pPage
= pDrawLayer
->GetPage(nTab
);
1612 DBG_ASSERT(pPage
,"Page ?");
1614 SdrObjListIter
aIter( *pPage
, IM_DEEPNOGROUPS
);
1615 SdrObject
* pObject
= aIter
.Next();
1618 if ( pObject
->GetObjIdentifier() == OBJ_OLE2
&&
1619 ((SdrOle2Obj
*)pObject
)->GetPersistName() == aPersistName
)
1624 pObject
= aIter
.Next();
1628 DBG_ERROR("Object not found");
1632 void ScUndoRenameObject::Undo()
1635 SdrObject
* pObj
= GetObject();
1637 pObj
->SetName( aOldName
);
1641 void ScUndoRenameObject::Redo()
1644 SdrObject
* pObj
= GetObject();
1646 pObj
->SetName( aNewName
);
1650 void ScUndoRenameObject::Repeat(SfxRepeatTarget
& /* rTarget */)
1654 BOOL
ScUndoRenameObject::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1659 // -----------------------------------------------------------------------
1661 // Switch sheet between left-to-right and right-to-left
1664 ScUndoLayoutRTL::ScUndoLayoutRTL( ScDocShell
* pShell
, SCTAB nNewTab
, BOOL bNewRTL
) :
1665 ScSimpleUndo( pShell
),
1671 ScUndoLayoutRTL::~ScUndoLayoutRTL()
1675 void ScUndoLayoutRTL::DoChange( BOOL bNew
)
1677 pDocShell
->SetInUndo( TRUE
);
1679 ScDocument
* pDoc
= pDocShell
->GetDocument();
1680 pDoc
->SetLayoutRTL( nTab
, bNew
);
1682 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1684 pViewShell
->SetTabNo(nTab
,TRUE
);
1686 pDocShell
->SetDocumentModified();
1688 pDocShell
->SetInUndo( FALSE
);
1691 void ScUndoLayoutRTL::Undo()
1696 void ScUndoLayoutRTL::Redo()
1701 void ScUndoLayoutRTL::Repeat(SfxRepeatTarget
& rTarget
)
1703 if (rTarget
.ISA(ScTabViewTarget
))
1704 ((ScTabViewTarget
&)rTarget
).GetViewShell()->GetViewData()->GetDispatcher().
1705 Execute( FID_TAB_RTL
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
1708 BOOL
ScUndoLayoutRTL::CanRepeat(SfxRepeatTarget
& rTarget
) const
1710 return (rTarget
.ISA(ScTabViewTarget
));
1713 String
ScUndoLayoutRTL::GetComment() const
1715 return ScGlobal::GetRscString( STR_UNDO_TAB_RTL
);
1720 // -----------------------------------------------------------------------
1722 // Set the grammar used for the sheet
1725 //UNUSED2009-05 ScUndoSetGrammar::ScUndoSetGrammar( ScDocShell* pShell,
1726 //UNUSED2009-05 formula::FormulaGrammar::Grammar eGrammar ) :
1727 //UNUSED2009-05 ScSimpleUndo( pShell ),
1728 //UNUSED2009-05 meNewGrammar( eGrammar )
1730 //UNUSED2009-05 meOldGrammar = pDocShell->GetDocument()->GetGrammar();
1733 //UNUSED2009-05 __EXPORT ScUndoSetGrammar::~ScUndoSetGrammar()
1737 //UNUSED2009-05 void ScUndoSetGrammar::DoChange( formula::FormulaGrammar::Grammar eGrammar )
1739 //UNUSED2009-05 pDocShell->SetInUndo( TRUE );
1740 //UNUSED2009-05 ScDocument* pDoc = pDocShell->GetDocument();
1741 //UNUSED2009-05 pDoc->SetGrammar( eGrammar );
1742 //UNUSED2009-05 pDocShell->SetDocumentModified();
1743 //UNUSED2009-05 pDocShell->SetInUndo( FALSE );
1746 //UNUSED2009-05 void __EXPORT ScUndoSetGrammar::Undo()
1748 //UNUSED2009-05 DoChange( meOldGrammar );
1751 //UNUSED2009-05 void __EXPORT ScUndoSetGrammar::Redo()
1753 //UNUSED2009-05 DoChange( meNewGrammar );
1756 //UNUSED2009-05 void __EXPORT ScUndoSetGrammar::Repeat(SfxRepeatTarget& /* rTarget */)
1758 //UNUSED2009-05 #if 0
1759 //UNUSED2009-05 // erAck: 2006-09-07T23:00+0200 commented out in CWS scr1c1
1760 //UNUSED2009-05 if (rTarget.ISA(ScTabViewTarget))
1761 //UNUSED2009-05 ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
1762 //UNUSED2009-05 Execute( FID_TAB_USE_R1C1, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
1763 //UNUSED2009-05 #endif
1766 //UNUSED2009-05 BOOL __EXPORT ScUndoSetGrammar::CanRepeat(SfxRepeatTarget& rTarget) const
1768 //UNUSED2009-05 return (rTarget.ISA(ScTabViewTarget));
1771 //UNUSED2009-05 String __EXPORT ScUndoSetGrammar::GetComment() const
1773 //UNUSED2009-05 return ScGlobal::GetRscString( STR_UNDO_TAB_R1C1 );