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