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 extern BOOL bDrawIsInUndo
; //! irgendwo als Member !!!
75 using namespace com::sun::star
;
76 using ::com::sun::star::uno::Sequence
;
77 using ::std::auto_ptr
;
79 // STATIC DATA -----------------------------------------------------------
81 TYPEINIT1(ScUndoInsertTab
, SfxUndoAction
);
82 TYPEINIT1(ScUndoInsertTables
, SfxUndoAction
);
83 TYPEINIT1(ScUndoDeleteTab
, SfxUndoAction
);
84 TYPEINIT1(ScUndoRenameTab
, SfxUndoAction
);
85 TYPEINIT1(ScUndoMoveTab
, SfxUndoAction
);
86 TYPEINIT1(ScUndoCopyTab
, SfxUndoAction
);
87 TYPEINIT1(ScUndoMakeScenario
, SfxUndoAction
);
88 TYPEINIT1(ScUndoImportTab
, SfxUndoAction
);
89 TYPEINIT1(ScUndoRemoveLink
, SfxUndoAction
);
90 TYPEINIT1(ScUndoShowHideTab
, SfxUndoAction
);
91 TYPEINIT1(ScUndoPrintRange
, SfxUndoAction
);
92 TYPEINIT1(ScUndoScenarioFlags
, SfxUndoAction
);
93 TYPEINIT1(ScUndoRenameObject
, SfxUndoAction
);
94 TYPEINIT1(ScUndoLayoutRTL
, SfxUndoAction
);
95 //UNUSED2009-05 TYPEINIT1(ScUndoSetGrammar, SfxUndoAction);
98 // -----------------------------------------------------------------------
103 ScUndoInsertTab::ScUndoInsertTab( ScDocShell
* pNewDocShell
,
106 const String
& rNewName
) :
107 ScSimpleUndo( pNewDocShell
),
108 sNewName( rNewName
),
113 pDrawUndo
= GetSdrUndoAction( pDocShell
->GetDocument() );
117 ScUndoInsertTab::~ScUndoInsertTab()
119 DeleteSdrUndoAction( pDrawUndo
);
122 String
ScUndoInsertTab::GetComment() const
125 return ScGlobal::GetRscString( STR_UNDO_APPEND_TAB
);
127 return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB
);
130 void ScUndoInsertTab::SetChangeTrack()
132 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
135 ScRange
aRange( 0, 0, nTab
, MAXCOL
, MAXROW
, nTab
);
136 pChangeTrack
->AppendInsert( aRange
);
137 nEndChangeAction
= pChangeTrack
->GetActionMax();
140 nEndChangeAction
= 0;
143 void ScUndoInsertTab::Undo()
145 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
146 pViewShell
->SetTabNo(nTab
);
148 pDocShell
->SetInUndo( TRUE
); //! BeginUndo
149 bDrawIsInUndo
= TRUE
;
150 pViewShell
->DeleteTable( nTab
, FALSE
);
151 bDrawIsInUndo
= FALSE
;
152 pDocShell
->SetInUndo( FALSE
); //! EndUndo
154 DoSdrUndoAction( pDrawUndo
, pDocShell
->GetDocument() );
156 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
158 pChangeTrack
->Undo( nEndChangeAction
, nEndChangeAction
);
160 // SetTabNo(...,TRUE) for all views to sync with drawing layer pages
161 pDocShell
->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB
) );
164 void ScUndoInsertTab::Redo()
166 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
168 RedoSdrUndoAction( pDrawUndo
); // Draw Redo first
170 pDocShell
->SetInUndo( TRUE
); //! BeginRedo
171 bDrawIsInUndo
= TRUE
;
173 pViewShell
->AppendTable( sNewName
, FALSE
);
176 pViewShell
->SetTabNo(nTab
);
177 pViewShell
->InsertTable( sNewName
, nTab
, FALSE
);
179 bDrawIsInUndo
= FALSE
;
180 pDocShell
->SetInUndo( FALSE
); //! EndRedo
185 void ScUndoInsertTab::Repeat(SfxRepeatTarget
& rTarget
)
187 if (rTarget
.ISA(ScTabViewTarget
))
188 ((ScTabViewTarget
&)rTarget
).GetViewShell()->GetViewData()->GetDispatcher().
189 Execute(FID_INS_TABLE
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
192 BOOL
ScUndoInsertTab::CanRepeat(SfxRepeatTarget
& rTarget
) const
194 return (rTarget
.ISA(ScTabViewTarget
));
197 // -----------------------------------------------------------------------
199 // Tabellen einfuegen
202 ScUndoInsertTables::ScUndoInsertTables( ScDocShell
* pNewDocShell
,
204 BOOL bApp
,SvStrings
*pNewNameList
) :
205 ScSimpleUndo( pNewDocShell
),
210 pNameList
= pNewNameList
;
211 pDrawUndo
= GetSdrUndoAction( pDocShell
->GetDocument() );
216 ScUndoInsertTables::~ScUndoInsertTables()
221 for(int i
=0;i
<pNameList
->Count();i
++)
223 pStr
=pNameList
->GetObject(sal::static_int_cast
<USHORT
>(i
));
226 pNameList
->Remove(0,pNameList
->Count());
229 DeleteSdrUndoAction( pDrawUndo
);
232 String
ScUndoInsertTables::GetComment() const
234 return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB
);
237 void ScUndoInsertTables::SetChangeTrack()
239 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
242 nStartChangeAction
= pChangeTrack
->GetActionMax() + 1;
243 nEndChangeAction
= 0;
244 ScRange
aRange( 0, 0, nTab
, MAXCOL
, MAXROW
, nTab
);
245 for( int i
= 0; i
< pNameList
->Count(); i
++ )
247 aRange
.aStart
.SetTab( sal::static_int_cast
<SCTAB
>( nTab
+ i
) );
248 aRange
.aEnd
.SetTab( sal::static_int_cast
<SCTAB
>( nTab
+ i
) );
249 pChangeTrack
->AppendInsert( aRange
);
250 nEndChangeAction
= pChangeTrack
->GetActionMax();
254 nStartChangeAction
= nEndChangeAction
= 0;
257 void ScUndoInsertTables::Undo()
259 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
260 pViewShell
->SetTabNo(nTab
);
262 pDocShell
->SetInUndo( TRUE
); //! BeginUndo
263 bDrawIsInUndo
= TRUE
;
266 for(int i
=0;i
<pNameList
->Count();i
++)
268 TheTabs
.Insert( sal::static_int_cast
<short>(nTab
+i
), TheTabs
.Count() );
271 pViewShell
->DeleteTables( TheTabs
, FALSE
);
272 TheTabs
.Remove(0,TheTabs
.Count());
274 bDrawIsInUndo
= FALSE
;
275 pDocShell
->SetInUndo( FALSE
); //! EndUndo
277 DoSdrUndoAction( pDrawUndo
, pDocShell
->GetDocument() );
279 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
281 pChangeTrack
->Undo( nStartChangeAction
, nEndChangeAction
);
283 // SetTabNo(...,TRUE) for all views to sync with drawing layer pages
284 pDocShell
->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB
) );
287 void ScUndoInsertTables::Redo()
289 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
291 RedoSdrUndoAction( pDrawUndo
); // Draw Redo first
293 pDocShell
->SetInUndo( TRUE
); //! BeginRedo
294 bDrawIsInUndo
= TRUE
;
295 pViewShell
->SetTabNo(nTab
);
296 pViewShell
->InsertTables( pNameList
, nTab
, static_cast<SCTAB
>(pNameList
->Count()),FALSE
);
298 bDrawIsInUndo
= FALSE
;
299 pDocShell
->SetInUndo( FALSE
); //! EndRedo
304 void ScUndoInsertTables::Repeat(SfxRepeatTarget
& rTarget
)
306 if (rTarget
.ISA(ScTabViewTarget
))
307 ((ScTabViewTarget
&)rTarget
).GetViewShell()->GetViewData()->GetDispatcher().
308 Execute(FID_INS_TABLE
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
311 BOOL
ScUndoInsertTables::CanRepeat(SfxRepeatTarget
& rTarget
) const
313 return (rTarget
.ISA(ScTabViewTarget
));
317 //----------------------------------------------------------------------------------
322 ScUndoDeleteTab::ScUndoDeleteTab( ScDocShell
* pNewDocShell
,const SvShorts
&aTab
, //SCTAB nNewTab,
323 ScDocument
* pUndoDocument
, ScRefUndoData
* pRefData
) :
324 ScMoveUndo( pNewDocShell
, pUndoDocument
, pRefData
, SC_UNDO_REFLAST
)
326 for(int i
=0;i
<aTab
.Count();i
++)
327 theTabs
.Insert(aTab
[sal::static_int_cast
<USHORT
>(i
)],theTabs
.Count());
332 ScUndoDeleteTab::~ScUndoDeleteTab()
334 theTabs
.Remove(0,theTabs
.Count());
337 String
ScUndoDeleteTab::GetComment() const
339 return ScGlobal::GetRscString( STR_UNDO_DELETE_TAB
);
342 void ScUndoDeleteTab::SetChangeTrack()
344 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
347 ULONG nTmpChangeAction
;
348 nStartChangeAction
= pChangeTrack
->GetActionMax() + 1;
349 nEndChangeAction
= 0;
350 ScRange
aRange( 0, 0, 0, MAXCOL
, MAXROW
, 0 );
351 for ( int i
= 0; i
< theTabs
.Count(); i
++ )
353 aRange
.aStart
.SetTab( theTabs
[sal::static_int_cast
<USHORT
>(i
)] );
354 aRange
.aEnd
.SetTab( theTabs
[sal::static_int_cast
<USHORT
>(i
)] );
355 pChangeTrack
->AppendDeleteRange( aRange
, pRefUndoDoc
,
356 nTmpChangeAction
, nEndChangeAction
, (short) i
);
360 nStartChangeAction
= nEndChangeAction
= 0;
363 SCTAB
lcl_GetVisibleTabBefore( ScDocument
& rDoc
, SCTAB nTab
)
365 while ( nTab
> 0 && !rDoc
.IsVisible( nTab
) )
371 void ScUndoDeleteTab::Undo()
375 ScDocument
* pDoc
= pDocShell
->GetDocument();
380 for(i
=0;i
<theTabs
.Count();i
++)
382 SCTAB nTab
= theTabs
[sal::static_int_cast
<USHORT
>(i
)];
383 pRefUndoDoc
->GetName( nTab
, aName
);
385 bDrawIsInUndo
= TRUE
;
386 BOOL bOk
= pDoc
->InsertTab( nTab
, aName
);
387 bDrawIsInUndo
= FALSE
;
390 // Ref-Undo passiert in EndUndo
391 // pUndoDoc->UndoToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,FALSE, pDoc );
392 pRefUndoDoc
->CopyToDocument(0,0,nTab
, MAXCOL
,MAXROW
,nTab
, IDF_ALL
,FALSE
, pDoc
);
395 pRefUndoDoc
->GetName( nTab
, aOldName
);
396 pDoc
->RenameTab( nTab
, aOldName
, FALSE
);
397 if (pRefUndoDoc
->IsLinked(nTab
))
399 pDoc
->SetLink( nTab
, pRefUndoDoc
->GetLinkMode(nTab
), pRefUndoDoc
->GetLinkDoc(nTab
),
400 pRefUndoDoc
->GetLinkFlt(nTab
), pRefUndoDoc
->GetLinkOpt(nTab
),
401 pRefUndoDoc
->GetLinkTab(nTab
), pRefUndoDoc
->GetLinkRefreshDelay(nTab
) );
405 if ( pRefUndoDoc
->IsScenario(nTab
) )
407 pDoc
->SetScenario( nTab
, TRUE
);
411 pRefUndoDoc
->GetScenarioData( nTab
, aComment
, aColor
, nScenFlags
);
412 pDoc
->SetScenarioData( nTab
, aComment
, aColor
, nScenFlags
);
413 BOOL bActive
= pRefUndoDoc
->IsActiveScenario( nTab
);
414 pDoc
->SetActiveScenario( nTab
, bActive
);
416 pDoc
->SetVisible( nTab
, pRefUndoDoc
->IsVisible( nTab
) );
418 if ( pRefUndoDoc
->IsTabProtected( nTab
) )
419 pDoc
->SetTabProtection(nTab
, pRefUndoDoc
->GetTabProtection(nTab
));
421 // Drawing-Layer passiert beim MoveUndo::EndUndo
422 // pDoc->TransferDrawPage(pRefUndoDoc, nTab,nTab);
427 pDocShell
->UpdateLinks(); // Link-Manager updaten
430 EndUndo(); // Draw-Undo muss vor dem Broadcast kommen!
432 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
434 pChangeTrack
->Undo( nStartChangeAction
, nEndChangeAction
);
436 for(i
=0;i
<theTabs
.Count();i
++)
438 pDocShell
->Broadcast( ScTablesHint( SC_TAB_INSERTED
, theTabs
[sal::static_int_cast
<USHORT
>(i
)]) );
440 SfxApplication
* pSfxApp
= SFX_APP(); // Navigator
441 pSfxApp
->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
442 pSfxApp
->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED
) );
443 pSfxApp
->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED
) );
445 pDocShell
->PostPaint(0,0,0, MAXCOL
,MAXROW
,MAXTAB
, PAINT_ALL
); // incl. Extras
447 // nicht ShowTable wegen SetTabNo(..., TRUE):
448 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
450 pViewShell
->SetTabNo( lcl_GetVisibleTabBefore( *pDoc
, theTabs
[0] ), TRUE
);
455 void ScUndoDeleteTab::Redo()
457 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
458 pViewShell
->SetTabNo( lcl_GetVisibleTabBefore( *pDocShell
->GetDocument(), theTabs
[0] ) );
460 RedoSdrUndoAction( pDrawUndo
); // Draw Redo first
462 pDocShell
->SetInUndo( TRUE
); //! BeginRedo
463 bDrawIsInUndo
= TRUE
;
464 pViewShell
->DeleteTables( theTabs
, FALSE
);
465 bDrawIsInUndo
= FALSE
;
466 pDocShell
->SetInUndo( TRUE
); //! EndRedo
470 // SetTabNo(...,TRUE) for all views to sync with drawing layer pages
471 pDocShell
->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB
) );
474 void ScUndoDeleteTab::Repeat(SfxRepeatTarget
& rTarget
)
476 if (rTarget
.ISA(ScTabViewTarget
))
478 ScTabViewShell
* pViewShell
= ((ScTabViewTarget
&)rTarget
).GetViewShell();
479 pViewShell
->DeleteTable( pViewShell
->GetViewData()->GetTabNo(), TRUE
);
483 BOOL
ScUndoDeleteTab::CanRepeat(SfxRepeatTarget
& rTarget
) const
485 return (rTarget
.ISA(ScTabViewTarget
));
489 //---------------------------------------------------------------------------------
491 // Tabelle umbenennen
494 ScUndoRenameTab::ScUndoRenameTab( ScDocShell
* pNewDocShell
,
496 const String
& rOldName
,
497 const String
& rNewName
) :
498 ScSimpleUndo( pNewDocShell
),
505 ScUndoRenameTab::~ScUndoRenameTab()
509 String
ScUndoRenameTab::GetComment() const
511 return ScGlobal::GetRscString( STR_UNDO_RENAME_TAB
);
514 void ScUndoRenameTab::DoChange( SCTAB nTabP
, const String
& rName
) const
516 ScDocument
* pDoc
= pDocShell
->GetDocument();
517 pDoc
->RenameTab( nTabP
, rName
);
519 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) ); // Navigator
521 pDocShell
->PostPaintGridAll();
522 pDocShell
->PostPaintExtras();
523 pDocShell
->PostDataChanged();
525 // Der Tabellenname koennte in einer Formel vorkommen...
526 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
528 pViewShell
->UpdateInputHandler();
531 void ScUndoRenameTab::Undo()
533 DoChange(nTab
, sOldName
);
536 void ScUndoRenameTab::Redo()
538 DoChange(nTab
, sNewName
);
541 void ScUndoRenameTab::Repeat(SfxRepeatTarget
& /* rTarget */)
543 // Repeat macht keinen Sinn
546 BOOL
ScUndoRenameTab::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
552 //----------------------------------------------------------------------------------
554 // Tabelle verschieben
557 ScUndoMoveTab::ScUndoMoveTab( ScDocShell
* pNewDocShell
,
558 const SvShorts
&aOldTab
,
559 const SvShorts
&aNewTab
) :
560 ScSimpleUndo( pNewDocShell
)
563 for(i
=0;i
<aOldTab
.Count();i
++)
564 theOldTabs
.Insert(aOldTab
[sal::static_int_cast
<USHORT
>(i
)],theOldTabs
.Count());
566 for(i
=0;i
<aNewTab
.Count();i
++)
567 theNewTabs
.Insert(aNewTab
[sal::static_int_cast
<USHORT
>(i
)],theNewTabs
.Count());
570 ScUndoMoveTab::~ScUndoMoveTab()
572 theNewTabs
.Remove(0,theNewTabs
.Count());
573 theOldTabs
.Remove(0,theOldTabs
.Count());
576 String
ScUndoMoveTab::GetComment() const
578 return ScGlobal::GetRscString( STR_UNDO_MOVE_TAB
);
581 void ScUndoMoveTab::DoChange( BOOL bUndo
) const
583 ScDocument
* pDoc
= pDocShell
->GetDocument();
584 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
588 for(int i
=theNewTabs
.Count()-1;i
>=0;i
--)
590 SCTAB nDestTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
591 SCTAB nOldTab
= theOldTabs
[sal::static_int_cast
<USHORT
>(i
)];
592 if (nDestTab
> MAXTAB
) // angehaengt ?
593 nDestTab
= pDoc
->GetTableCount() - 1;
595 pDoc
->MoveTab( nDestTab
, nOldTab
);
596 pViewShell
->GetViewData()->MoveTab( nDestTab
, nOldTab
);
597 pViewShell
->SetTabNo( nOldTab
, TRUE
);
602 for(int i
=0;i
<theNewTabs
.Count();i
++)
604 SCTAB nDestTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
605 SCTAB nNewTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
606 SCTAB nOldTab
= theOldTabs
[sal::static_int_cast
<USHORT
>(i
)];
607 if (nDestTab
> MAXTAB
) // angehaengt ?
608 nDestTab
= pDoc
->GetTableCount() - 1;
610 pDoc
->MoveTab( nOldTab
, nNewTab
);
611 pViewShell
->GetViewData()->MoveTab( nOldTab
, nNewTab
);
612 pViewShell
->SetTabNo( nDestTab
, TRUE
);
616 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) ); // Navigator
618 pDocShell
->PostPaintGridAll();
619 pDocShell
->PostPaintExtras();
620 pDocShell
->PostDataChanged();
623 void ScUndoMoveTab::Undo()
628 void ScUndoMoveTab::Redo()
633 void ScUndoMoveTab::Repeat(SfxRepeatTarget
& /* rTarget */)
638 BOOL
ScUndoMoveTab::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
644 //----------------------------------------------------------------------------------
649 ScUndoCopyTab::ScUndoCopyTab( ScDocShell
* pNewDocShell
,
650 const SvShorts
&aOldTab
,
651 const SvShorts
&aNewTab
) :
652 ScSimpleUndo( pNewDocShell
),
655 pDrawUndo
= GetSdrUndoAction( pDocShell
->GetDocument() );
658 for(i
=0;i
<aOldTab
.Count();i
++)
659 theOldTabs
.Insert(aOldTab
[sal::static_int_cast
<USHORT
>(i
)],theOldTabs
.Count());
661 for(i
=0;i
<aNewTab
.Count();i
++)
662 theNewTabs
.Insert(aNewTab
[sal::static_int_cast
<USHORT
>(i
)],theNewTabs
.Count());
665 ScUndoCopyTab::~ScUndoCopyTab()
667 DeleteSdrUndoAction( pDrawUndo
);
670 String
ScUndoCopyTab::GetComment() const
672 return ScGlobal::GetRscString( STR_UNDO_COPY_TAB
);
675 void ScUndoCopyTab::DoChange() const
677 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
680 pViewShell
->SetTabNo(theOldTabs
[0],TRUE
);
682 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) ); // Navigator
684 pDocShell
->PostPaintGridAll();
685 pDocShell
->PostPaintExtras();
686 pDocShell
->PostDataChanged();
689 void ScUndoCopyTab::Undo()
691 ScDocument
* pDoc
= pDocShell
->GetDocument();
693 DoSdrUndoAction( pDrawUndo
, pDoc
); // before the sheets are deleted
696 for(i
=theNewTabs
.Count()-1;i
>=0;i
--)
698 SCTAB nDestTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
699 if (nDestTab
> MAXTAB
) // append?
700 nDestTab
= pDoc
->GetTableCount() - 1;
702 bDrawIsInUndo
= TRUE
;
703 pDoc
->DeleteTab(nDestTab
);
704 bDrawIsInUndo
= FALSE
;
707 // ScTablesHint broadcasts after all sheets have been deleted,
708 // so sheets and draw pages are in sync!
710 for(i
=theNewTabs
.Count()-1;i
>=0;i
--)
712 SCTAB nDestTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
713 if (nDestTab
> MAXTAB
) // append?
714 nDestTab
= pDoc
->GetTableCount() - 1;
716 pDocShell
->Broadcast( ScTablesHint( SC_TAB_DELETED
, nDestTab
) );
722 void ScUndoCopyTab::Redo()
724 ScDocument
* pDoc
= pDocShell
->GetDocument();
725 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
728 for(int i
=0;i
<theNewTabs
.Count();i
++)
730 nDestTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
731 SCTAB nNewTab
= theNewTabs
[sal::static_int_cast
<USHORT
>(i
)];
732 SCTAB nOldTab
= theOldTabs
[sal::static_int_cast
<USHORT
>(i
)];
733 if (nDestTab
> MAXTAB
) // angehaengt ?
734 nDestTab
= pDoc
->GetTableCount() - 1;
736 bDrawIsInUndo
= TRUE
;
737 pDoc
->CopyTab( nOldTab
, nNewTab
);
738 bDrawIsInUndo
= FALSE
;
740 pViewShell
->GetViewData()->MoveTab( nOldTab
, nNewTab
);
742 SCTAB nAdjSource
= nOldTab
;
743 if ( nNewTab
<= nOldTab
)
744 ++nAdjSource
; // new position of source table after CopyTab
746 if ( pDoc
->IsScenario(nAdjSource
) )
748 pDoc
->SetScenario(nNewTab
, TRUE
);
752 pDoc
->GetScenarioData(nAdjSource
, aComment
, aColor
, nScenFlags
);
753 pDoc
->SetScenarioData(nNewTab
, aComment
, aColor
, nScenFlags
);
754 BOOL bActive
= pDoc
->IsActiveScenario(nAdjSource
);
755 pDoc
->SetActiveScenario(nNewTab
, bActive
);
756 BOOL bVisible
=pDoc
->IsVisible(nAdjSource
);
757 pDoc
->SetVisible(nNewTab
,bVisible
);
760 if ( pDoc
->IsTabProtected( nAdjSource
) )
761 pDoc
->CopyTabProtection(nAdjSource
, nNewTab
);
764 RedoSdrUndoAction( pDrawUndo
); // after the sheets are inserted
766 pViewShell
->SetTabNo( nDestTab
, TRUE
); // after draw-undo
772 void ScUndoCopyTab::Repeat(SfxRepeatTarget
& /* rTarget */)
777 BOOL
ScUndoCopyTab::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
783 // -----------------------------------------------------------------------
788 ScUndoMakeScenario::ScUndoMakeScenario( ScDocShell
* pNewDocShell
,
789 SCTAB nSrc
, SCTAB nDest
,
790 const String
& rN
, const String
& rC
,
791 const Color
& rCol
, USHORT nF
,
792 const ScMarkData
& rMark
) :
793 ScSimpleUndo( pNewDocShell
),
803 pDrawUndo
= GetSdrUndoAction( pDocShell
->GetDocument() );
806 ScUndoMakeScenario::~ScUndoMakeScenario()
808 DeleteSdrUndoAction( pDrawUndo
);
811 String
ScUndoMakeScenario::GetComment() const
813 return ScGlobal::GetRscString( STR_UNDO_MAKESCENARIO
);
816 void ScUndoMakeScenario::Undo()
818 ScDocument
* pDoc
= pDocShell
->GetDocument();
820 pDocShell
->SetInUndo( TRUE
);
821 bDrawIsInUndo
= TRUE
;
822 pDoc
->DeleteTab( nDestTab
);
823 bDrawIsInUndo
= FALSE
;
824 pDocShell
->SetInUndo( FALSE
);
826 DoSdrUndoAction( pDrawUndo
, pDoc
);
828 pDocShell
->PostPaint(0,0,nDestTab
,MAXCOL
,MAXROW
,MAXTAB
, PAINT_ALL
);
829 pDocShell
->PostDataChanged();
831 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
833 pViewShell
->SetTabNo( nSrcTab
, TRUE
);
835 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
837 // SetTabNo(...,TRUE) for all views to sync with drawing layer pages
838 pDocShell
->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB
) );
841 void ScUndoMakeScenario::Redo()
843 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
845 pViewShell
->SetMarkData( aMarkData
);
847 RedoSdrUndoAction( pDrawUndo
); // Draw Redo first
849 pDocShell
->SetInUndo( TRUE
);
850 bDrawIsInUndo
= TRUE
;
852 pDocShell
->MakeScenario( nSrcTab
, aName
, aComment
, aColor
, nFlags
, aMarkData
, FALSE
);
854 bDrawIsInUndo
= FALSE
;
855 pDocShell
->SetInUndo( FALSE
);
858 pViewShell
->SetTabNo( nDestTab
, TRUE
);
860 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
863 void ScUndoMakeScenario::Repeat(SfxRepeatTarget
& rTarget
)
865 if (rTarget
.ISA(ScTabViewTarget
))
867 ((ScTabViewTarget
&)rTarget
).GetViewShell()->MakeScenario( aName
, aComment
, aColor
, nFlags
);
871 BOOL
ScUndoMakeScenario::CanRepeat(SfxRepeatTarget
& rTarget
) const
873 return (rTarget
.ISA(ScTabViewTarget
));
877 // -----------------------------------------------------------------------
882 ScUndoImportTab::ScUndoImportTab( ScDocShell
* pShell
,
883 SCTAB nNewTab
, SCTAB nNewCount
, BOOL bNewLink
) :
884 ScSimpleUndo( pShell
),
891 pDrawUndo
= GetSdrUndoAction( pDocShell
->GetDocument() );
894 ScUndoImportTab::~ScUndoImportTab()
897 DeleteSdrUndoAction( pDrawUndo
);
900 String
ScUndoImportTab::GetComment() const
902 return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB
);
905 void ScUndoImportTab::DoChange() const
907 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
908 ScDocument
* pDoc
= pDocShell
->GetDocument();
909 SCTAB nTabCount
= pDoc
->GetTableCount();
914 pViewShell
->SetTabNo(nTab
,TRUE
);
918 pViewShell
->SetTabNo(nTab
-1,TRUE
);
922 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) ); // Navigator
923 pDocShell
->PostPaint( 0,0,0, MAXCOL
,MAXROW
,MAXTAB
,
924 PAINT_GRID
| PAINT_TOP
| PAINT_LEFT
| PAINT_EXTRAS
);
927 void ScUndoImportTab::Undo()
929 //! eingefuegte Bereichsnamen etc.
932 ScDocument
* pDoc
= pDocShell
->GetDocument();
933 BOOL bMakeRedo
= !pRedoDoc
;
936 pRedoDoc
= new ScDocument( SCDOCMODE_UNDO
);
937 pRedoDoc
->InitUndo( pDoc
, nTab
,nTab
+nCount
-1, TRUE
,TRUE
);
940 for (i
=0; i
<nCount
; i
++)
942 SCTAB nTabPos
=nTab
+i
;
944 pDoc
->CopyToDocument(0,0,nTabPos
, MAXCOL
,MAXROW
,nTabPos
, IDF_ALL
,FALSE
, pRedoDoc
);
945 pDoc
->GetName( nTabPos
, aOldName
);
946 pRedoDoc
->RenameTab( nTabPos
, aOldName
, FALSE
);
948 if ( pDoc
->IsScenario(nTabPos
) )
950 pRedoDoc
->SetScenario(nTabPos
, TRUE
);
954 pDoc
->GetScenarioData(nTabPos
, aComment
, aColor
, nScenFlags
);
955 pRedoDoc
->SetScenarioData(nTabPos
, aComment
, aColor
, nScenFlags
);
956 BOOL bActive
= pDoc
->IsActiveScenario(nTabPos
);
957 pRedoDoc
->SetActiveScenario(nTabPos
, bActive
);
958 BOOL bVisible
=pDoc
->IsVisible(nTabPos
);
959 pRedoDoc
->SetVisible(nTabPos
,bVisible
);
962 if ( pDoc
->IsTabProtected( nTabPos
) )
963 pRedoDoc
->SetTabProtection(nTabPos
, pDoc
->GetTabProtection(nTabPos
));
968 DoSdrUndoAction( pDrawUndo
, pDoc
); // before the sheets are deleted
970 bDrawIsInUndo
= TRUE
;
971 for (i
=0; i
<nCount
; i
++)
972 pDoc
->DeleteTab( nTab
);
973 bDrawIsInUndo
= FALSE
;
978 void ScUndoImportTab::Redo()
982 DBG_ERROR("wo ist mein Redo-Document?");
986 ScDocument
* pDoc
= pDocShell
->GetDocument();
989 for (i
=0; i
<nCount
; i
++) // first insert all sheets (#63304#)
991 SCTAB nTabPos
=nTab
+i
;
992 pRedoDoc
->GetName(nTabPos
,aName
);
993 bDrawIsInUndo
= TRUE
;
994 pDoc
->InsertTab(nTabPos
,aName
);
995 bDrawIsInUndo
= FALSE
;
997 for (i
=0; i
<nCount
; i
++) // then copy into inserted sheets
999 SCTAB nTabPos
=nTab
+i
;
1000 pRedoDoc
->CopyToDocument(0,0,nTabPos
, MAXCOL
,MAXROW
,nTabPos
, IDF_ALL
,FALSE
, pDoc
);
1002 if ( pRedoDoc
->IsScenario(nTabPos
) )
1004 pDoc
->SetScenario(nTabPos
, TRUE
);
1008 pRedoDoc
->GetScenarioData(nTabPos
, aComment
, aColor
, nScenFlags
);
1009 pDoc
->SetScenarioData(nTabPos
, aComment
, aColor
, nScenFlags
);
1010 BOOL bActive
= pRedoDoc
->IsActiveScenario(nTabPos
);
1011 pDoc
->SetActiveScenario(nTabPos
, bActive
);
1012 BOOL bVisible
=pRedoDoc
->IsVisible(nTabPos
);
1013 pDoc
->SetVisible(nTabPos
,bVisible
);
1016 if ( pRedoDoc
->IsTabProtected( nTabPos
) )
1017 pDoc
->SetTabProtection(nTabPos
, pRedoDoc
->GetTabProtection(nTabPos
));
1020 RedoSdrUndoAction( pDrawUndo
); // after the sheets are inserted
1025 void ScUndoImportTab::Repeat(SfxRepeatTarget
& rTarget
)
1027 if (rTarget
.ISA(ScTabViewTarget
))
1028 ((ScTabViewTarget
&)rTarget
).GetViewShell()->GetViewData()->GetDispatcher().
1029 Execute(FID_INS_TABLE
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
1032 BOOL
ScUndoImportTab::CanRepeat(SfxRepeatTarget
& rTarget
) const
1034 return (rTarget
.ISA(ScTabViewTarget
));
1038 // -----------------------------------------------------------------------
1040 // Tabellen-Verknuepfung aufheben
1043 ScUndoRemoveLink::ScUndoRemoveLink( ScDocShell
* pShell
, const String
& rDoc
) :
1044 ScSimpleUndo( pShell
),
1048 ScDocument
* pDoc
= pDocShell
->GetDocument();
1049 SCTAB nTabCount
= pDoc
->GetTableCount();
1050 pTabs
= new SCTAB
[nTabCount
];
1051 pModes
= new BYTE
[nTabCount
];
1052 pTabNames
= new String
[nTabCount
];
1054 for (SCTAB i
=0; i
<nTabCount
; i
++)
1056 BYTE nMode
= pDoc
->GetLinkMode(i
);
1058 if (pDoc
->GetLinkDoc(i
) == aDocName
)
1062 aFltName
= pDoc
->GetLinkFlt(i
);
1063 aOptions
= pDoc
->GetLinkOpt(i
);
1064 nRefreshDelay
= pDoc
->GetLinkRefreshDelay(i
);
1068 DBG_ASSERT(aFltName
== pDoc
->GetLinkFlt(i
) &&
1069 aOptions
== pDoc
->GetLinkOpt(i
),
1070 "verschiedene Filter fuer ein Dokument?");
1073 pModes
[nCount
] = nMode
;
1074 pTabNames
[nCount
] = pDoc
->GetLinkTab(i
);
1080 ScUndoRemoveLink::~ScUndoRemoveLink()
1087 String
ScUndoRemoveLink::GetComment() const
1089 return ScGlobal::GetRscString( STR_UNDO_REMOVELINK
);
1092 void ScUndoRemoveLink::DoChange( BOOL bLink
) const
1094 ScDocument
* pDoc
= pDocShell
->GetDocument();
1096 for (USHORT i
=0; i
<nCount
; i
++)
1097 if (bLink
) // establish link
1098 pDoc
->SetLink( pTabs
[i
], pModes
[i
], aDocName
, aFltName
, aOptions
, pTabNames
[i
], nRefreshDelay
);
1100 pDoc
->SetLink( pTabs
[i
], SC_LINK_NONE
, aEmpty
, aEmpty
, aEmpty
, aEmpty
, 0 );
1101 pDocShell
->UpdateLinks();
1104 void ScUndoRemoveLink::Undo()
1109 void ScUndoRemoveLink::Redo()
1114 void ScUndoRemoveLink::Repeat(SfxRepeatTarget
& /* rTarget */)
1119 BOOL
ScUndoRemoveLink::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1125 // -----------------------------------------------------------------------
1127 // Tabellen ein-/ausblenden
1130 ScUndoShowHideTab::ScUndoShowHideTab( ScDocShell
* pShell
, SCTAB nNewTab
, BOOL bNewShow
) :
1131 ScSimpleUndo( pShell
),
1137 ScUndoShowHideTab::~ScUndoShowHideTab()
1141 void ScUndoShowHideTab::DoChange( BOOL bShowP
) const
1143 ScDocument
* pDoc
= pDocShell
->GetDocument();
1144 pDoc
->SetVisible( nTab
, bShowP
);
1146 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1148 pViewShell
->SetTabNo(nTab
,TRUE
);
1150 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
1151 pDocShell
->SetDocumentModified();
1154 void ScUndoShowHideTab::Undo()
1159 void ScUndoShowHideTab::Redo()
1164 void ScUndoShowHideTab::Repeat(SfxRepeatTarget
& rTarget
)
1166 if (rTarget
.ISA(ScTabViewTarget
))
1167 ((ScTabViewTarget
&)rTarget
).GetViewShell()->GetViewData()->GetDispatcher().
1168 Execute( bShow
? FID_TABLE_SHOW
: FID_TABLE_HIDE
,
1169 SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
1172 BOOL
ScUndoShowHideTab::CanRepeat(SfxRepeatTarget
& rTarget
) const
1174 return (rTarget
.ISA(ScTabViewTarget
));
1177 String
ScUndoShowHideTab::GetComment() const
1179 USHORT nId
= bShow
? STR_UNDO_SHOWTAB
: STR_UNDO_HIDETAB
;
1180 return ScGlobal::GetRscString( nId
);
1183 // ============================================================================
1185 ScUndoDocProtect::ScUndoDocProtect(ScDocShell
* pShell
, auto_ptr
<ScDocProtection
> pProtectSettings
) :
1186 ScSimpleUndo(pShell
),
1187 mpProtectSettings(pProtectSettings
)
1191 ScUndoDocProtect::~ScUndoDocProtect()
1195 void ScUndoDocProtect::DoProtect(bool bProtect
)
1197 ScDocument
* pDoc
= pDocShell
->GetDocument();
1202 auto_ptr
<ScDocProtection
> pCopy(new ScDocProtection(*mpProtectSettings
));
1203 pCopy
->setProtected(true);
1204 pDoc
->SetDocProtection(pCopy
.get());
1208 // remove protection.
1209 pDoc
->SetDocProtection(NULL
);
1212 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1215 pViewShell
->UpdateLayerLocks();
1216 pViewShell
->UpdateInputHandler(TRUE
); // damit sofort wieder eingegeben werden kann
1219 pDocShell
->PostPaintGridAll();
1222 void ScUndoDocProtect::Undo()
1225 DoProtect(!mpProtectSettings
->isProtected());
1229 void ScUndoDocProtect::Redo()
1232 DoProtect(mpProtectSettings
->isProtected());
1236 void ScUndoDocProtect::Repeat(SfxRepeatTarget
& /* rTarget */)
1241 BOOL
ScUndoDocProtect::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1243 return FALSE
; // gippsnich
1246 String
ScUndoDocProtect::GetComment() const
1248 USHORT nId
= mpProtectSettings
->isProtected() ? STR_UNDO_PROTECT_DOC
: STR_UNDO_UNPROTECT_DOC
;
1249 return ScGlobal::GetRscString( nId
);
1252 // ============================================================================
1254 ScUndoTabProtect::ScUndoTabProtect(ScDocShell
* pShell
, SCTAB nTab
, auto_ptr
<ScTableProtection
> pProtectSettings
) :
1255 ScSimpleUndo(pShell
),
1257 mpProtectSettings(pProtectSettings
)
1261 ScUndoTabProtect::~ScUndoTabProtect()
1265 void ScUndoTabProtect::DoProtect(bool bProtect
)
1267 ScDocument
* pDoc
= pDocShell
->GetDocument();
1272 auto_ptr
<ScTableProtection
> pCopy(new ScTableProtection(*mpProtectSettings
));
1273 pCopy
->setProtected(true);
1274 pDoc
->SetTabProtection(mnTab
, pCopy
.get());
1278 // remove protection.
1279 pDoc
->SetTabProtection(mnTab
, NULL
);
1282 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1285 pViewShell
->UpdateLayerLocks();
1286 pViewShell
->UpdateInputHandler(TRUE
); // damit sofort wieder eingegeben werden kann
1289 pDocShell
->PostPaintGridAll();
1292 void ScUndoTabProtect::Undo()
1295 DoProtect(!mpProtectSettings
->isProtected());
1299 void ScUndoTabProtect::Redo()
1302 DoProtect(mpProtectSettings
->isProtected());
1306 void ScUndoTabProtect::Repeat(SfxRepeatTarget
& /* rTarget */)
1311 BOOL
ScUndoTabProtect::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1313 return FALSE
; // gippsnich
1316 String
ScUndoTabProtect::GetComment() const
1318 USHORT nId
= mpProtectSettings
->isProtected() ? STR_UNDO_PROTECT_TAB
: STR_UNDO_UNPROTECT_TAB
;
1319 return ScGlobal::GetRscString( nId
);
1322 // -----------------------------------------------------------------------
1324 // Druck-/Wiederholungsbereiche aendern
1327 ScUndoPrintRange::ScUndoPrintRange( ScDocShell
* pShell
, SCTAB nNewTab
,
1328 ScPrintRangeSaver
* pOld
, ScPrintRangeSaver
* pNew
) :
1329 ScSimpleUndo( pShell
),
1336 ScUndoPrintRange::~ScUndoPrintRange()
1342 void ScUndoPrintRange::DoChange(BOOL bUndo
)
1344 ScDocument
* pDoc
= pDocShell
->GetDocument();
1346 pDoc
->RestorePrintRanges( *pOldRanges
);
1348 pDoc
->RestorePrintRanges( *pNewRanges
);
1350 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1352 pViewShell
->SetTabNo( nTab
);
1354 ScPrintFunc( pDocShell
, pDocShell
->GetPrinter(), nTab
).UpdatePages();
1356 pDocShell
->PostPaint( ScRange(0,0,nTab
,MAXCOL
,MAXROW
,nTab
), PAINT_GRID
);
1359 void ScUndoPrintRange::Undo()
1366 void ScUndoPrintRange::Redo()
1373 void ScUndoPrintRange::Repeat(SfxRepeatTarget
& /* rTarget */)
1378 BOOL
ScUndoPrintRange::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1380 return FALSE
; // gippsnich
1383 String
ScUndoPrintRange::GetComment() const
1385 return ScGlobal::GetRscString( STR_UNDO_PRINTRANGES
);
1389 //------------------------------------------------------------------------
1391 //---------------------------------------------------------------------------------
1396 ScUndoScenarioFlags::ScUndoScenarioFlags( ScDocShell
* pNewDocShell
, SCTAB nT
,
1397 const String
& rON
, const String
& rNN
, const String
& rOC
, const String
& rNC
,
1398 const Color
& rOCol
, const Color
& rNCol
, USHORT nOF
, USHORT nNF
) :
1399 ScSimpleUndo( pNewDocShell
),
1403 aOldComment ( rOC
),
1404 aNewComment ( rNC
),
1405 aOldColor ( rOCol
),
1406 aNewColor ( rNCol
),
1412 ScUndoScenarioFlags::~ScUndoScenarioFlags()
1416 String
ScUndoScenarioFlags::GetComment() const
1418 return ScGlobal::GetRscString( STR_UNDO_EDITSCENARIO
);
1421 void ScUndoScenarioFlags::Undo()
1423 ScDocument
* pDoc
= pDocShell
->GetDocument();
1425 pDoc
->RenameTab( nTab
, aOldName
);
1426 pDoc
->SetScenarioData( nTab
, aOldComment
, aOldColor
, nOldFlags
);
1428 pDocShell
->PostPaintGridAll();
1429 // Der Tabellenname koennte in einer Formel vorkommen...
1430 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1432 pViewShell
->UpdateInputHandler();
1434 if ( aOldName
!= aNewName
)
1435 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
1438 void ScUndoScenarioFlags::Redo()
1440 ScDocument
* pDoc
= pDocShell
->GetDocument();
1442 pDoc
->RenameTab( nTab
, aNewName
);
1443 pDoc
->SetScenarioData( nTab
, aNewComment
, aNewColor
, nNewFlags
);
1445 pDocShell
->PostPaintGridAll();
1446 // Der Tabellenname koennte in einer Formel vorkommen...
1447 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1449 pViewShell
->UpdateInputHandler();
1451 if ( aOldName
!= aNewName
)
1452 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED
) );
1455 void ScUndoScenarioFlags::Repeat(SfxRepeatTarget
& /* rTarget */)
1457 // Repeat macht keinen Sinn
1460 BOOL
ScUndoScenarioFlags::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1466 //---------------------------------------------------------------------------------
1469 // (move to different file?)
1472 ScUndoRenameObject::ScUndoRenameObject( ScDocShell
* pNewDocShell
, const String
& rPN
,
1473 const String
& rON
, const String
& rNN
) :
1474 ScSimpleUndo( pNewDocShell
),
1475 aPersistName( rPN
),
1481 ScUndoRenameObject::~ScUndoRenameObject()
1485 String
ScUndoRenameObject::GetComment() const
1487 // string resource shared with title for dialog
1488 return String( ScResId(SCSTR_RENAMEOBJECT
) );
1491 SdrObject
* ScUndoRenameObject::GetObject()
1493 ScDocument
* pDoc
= pDocShell
->GetDocument();
1494 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
1497 USHORT nCount
= pDrawLayer
->GetPageCount();
1498 for (USHORT nTab
=0; nTab
<nCount
; nTab
++)
1500 SdrPage
* pPage
= pDrawLayer
->GetPage(nTab
);
1501 DBG_ASSERT(pPage
,"Page ?");
1503 SdrObjListIter
aIter( *pPage
, IM_DEEPNOGROUPS
);
1504 SdrObject
* pObject
= aIter
.Next();
1507 if ( pObject
->GetObjIdentifier() == OBJ_OLE2
&&
1508 ((SdrOle2Obj
*)pObject
)->GetPersistName() == aPersistName
)
1513 pObject
= aIter
.Next();
1517 DBG_ERROR("Object not found");
1521 void ScUndoRenameObject::Undo()
1524 SdrObject
* pObj
= GetObject();
1526 pObj
->SetName( aOldName
);
1530 void ScUndoRenameObject::Redo()
1533 SdrObject
* pObj
= GetObject();
1535 pObj
->SetName( aNewName
);
1539 void ScUndoRenameObject::Repeat(SfxRepeatTarget
& /* rTarget */)
1543 BOOL
ScUndoRenameObject::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1548 // -----------------------------------------------------------------------
1550 // Switch sheet between left-to-right and right-to-left
1553 ScUndoLayoutRTL::ScUndoLayoutRTL( ScDocShell
* pShell
, SCTAB nNewTab
, BOOL bNewRTL
) :
1554 ScSimpleUndo( pShell
),
1560 ScUndoLayoutRTL::~ScUndoLayoutRTL()
1564 void ScUndoLayoutRTL::DoChange( BOOL bNew
)
1566 pDocShell
->SetInUndo( TRUE
);
1568 ScDocument
* pDoc
= pDocShell
->GetDocument();
1569 pDoc
->SetLayoutRTL( nTab
, bNew
);
1571 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1573 pViewShell
->SetTabNo(nTab
,TRUE
);
1575 pDocShell
->SetDocumentModified();
1577 pDocShell
->SetInUndo( FALSE
);
1580 void ScUndoLayoutRTL::Undo()
1585 void ScUndoLayoutRTL::Redo()
1590 void ScUndoLayoutRTL::Repeat(SfxRepeatTarget
& rTarget
)
1592 if (rTarget
.ISA(ScTabViewTarget
))
1593 ((ScTabViewTarget
&)rTarget
).GetViewShell()->GetViewData()->GetDispatcher().
1594 Execute( FID_TAB_RTL
, SFX_CALLMODE_SLOT
| SFX_CALLMODE_RECORD
);
1597 BOOL
ScUndoLayoutRTL::CanRepeat(SfxRepeatTarget
& rTarget
) const
1599 return (rTarget
.ISA(ScTabViewTarget
));
1602 String
ScUndoLayoutRTL::GetComment() const
1604 return ScGlobal::GetRscString( STR_UNDO_TAB_RTL
);
1609 // -----------------------------------------------------------------------
1611 // Set the grammar used for the sheet
1614 //UNUSED2009-05 ScUndoSetGrammar::ScUndoSetGrammar( ScDocShell* pShell,
1615 //UNUSED2009-05 formula::FormulaGrammar::Grammar eGrammar ) :
1616 //UNUSED2009-05 ScSimpleUndo( pShell ),
1617 //UNUSED2009-05 meNewGrammar( eGrammar )
1619 //UNUSED2009-05 meOldGrammar = pDocShell->GetDocument()->GetGrammar();
1622 //UNUSED2009-05 __EXPORT ScUndoSetGrammar::~ScUndoSetGrammar()
1626 //UNUSED2009-05 void ScUndoSetGrammar::DoChange( formula::FormulaGrammar::Grammar eGrammar )
1628 //UNUSED2009-05 pDocShell->SetInUndo( TRUE );
1629 //UNUSED2009-05 ScDocument* pDoc = pDocShell->GetDocument();
1630 //UNUSED2009-05 pDoc->SetGrammar( eGrammar );
1631 //UNUSED2009-05 pDocShell->SetDocumentModified();
1632 //UNUSED2009-05 pDocShell->SetInUndo( FALSE );
1635 //UNUSED2009-05 void __EXPORT ScUndoSetGrammar::Undo()
1637 //UNUSED2009-05 DoChange( meOldGrammar );
1640 //UNUSED2009-05 void __EXPORT ScUndoSetGrammar::Redo()
1642 //UNUSED2009-05 DoChange( meNewGrammar );
1645 //UNUSED2009-05 void __EXPORT ScUndoSetGrammar::Repeat(SfxRepeatTarget& /* rTarget */)
1647 //UNUSED2009-05 #if 0
1648 //UNUSED2009-05 // erAck: 2006-09-07T23:00+0200 commented out in CWS scr1c1
1649 //UNUSED2009-05 if (rTarget.ISA(ScTabViewTarget))
1650 //UNUSED2009-05 ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
1651 //UNUSED2009-05 Execute( FID_TAB_USE_R1C1, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
1652 //UNUSED2009-05 #endif
1655 //UNUSED2009-05 BOOL __EXPORT ScUndoSetGrammar::CanRepeat(SfxRepeatTarget& rTarget) const
1657 //UNUSED2009-05 return (rTarget.ISA(ScTabViewTarget));
1660 //UNUSED2009-05 String __EXPORT ScUndoSetGrammar::GetComment() const
1662 //UNUSED2009-05 return ScGlobal::GetRscString( STR_UNDO_TAB_R1C1 );