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 : : #include "scitems.hxx"
30 : : #include <svx/algitem.hxx>
31 : : #include <editeng/boxitem.hxx>
32 : : #include <editeng/justifyitem.hxx>
33 : : #include <svl/srchitem.hxx>
34 : : #include <sfx2/linkmgr.hxx>
35 : : #include <sfx2/bindings.hxx>
36 : : #include <vcl/virdev.hxx>
37 : : #include <sfx2/app.hxx>
38 : :
39 : : #include "undoblk.hxx"
40 : : #include "sc.hrc"
41 : : #include "globstr.hrc"
42 : : #include "global.hxx"
43 : : #include "rangenam.hxx"
44 : : #include "arealink.hxx"
45 : : #include "patattr.hxx"
46 : : #include "target.hxx"
47 : : #include "document.hxx"
48 : : #include "docpool.hxx"
49 : : #include "table.hxx"
50 : : #include "docsh.hxx"
51 : : #include "tabvwsh.hxx"
52 : : #include "undoolk.hxx"
53 : : #include "undoutil.hxx"
54 : : #include "chgtrack.hxx"
55 : : #include "dociter.hxx"
56 : : #include "cell.hxx"
57 : : #include "paramisc.hxx"
58 : : #include "postit.hxx"
59 : : #include "docuno.hxx"
60 : : #include "progress.hxx"
61 : :
62 : : // STATIC DATA ---------------------------------------------------------------
63 : :
64 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoDeleteContents, SfxUndoAction);
65 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoFillTable, SfxUndoAction);
66 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoSelectionAttr, SfxUndoAction);
67 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoAutoFill, SfxUndoAction);
68 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoMerge, SfxUndoAction);
69 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoAutoFormat, SfxUndoAction);
70 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoReplace, SfxUndoAction);
71 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoTabOp, SfxUndoAction);
72 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoConversion, SfxUndoAction);
73 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoRefConversion, SfxUndoAction);
74 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoRefreshLink, SfxUndoAction);
75 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoInsertAreaLink, SfxUndoAction);
76 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoRemoveAreaLink, SfxUndoAction);
77 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoUpdateAreaLink, SfxUndoAction);
78 : :
79 : :
80 : : // To Do:
81 : : /*A*/ // SetOptimalHeight auf Dokument, wenn keine View
82 : :
83 : :
84 : : //============================================================================
85 : : // class ScUndoDeleteContents
86 : : //
87 : : // Inhalte loeschen
88 : :
89 : : //----------------------------------------------------------------------------
90 : :
91 : 8 : ScUndoDeleteContents::ScUndoDeleteContents(
92 : : ScDocShell* pNewDocShell,
93 : : const ScMarkData& rMark, const ScRange& rRange,
94 : : ScDocument* pNewUndoDoc, sal_Bool bNewMulti,
95 : : sal_uInt16 nNewFlags, sal_Bool bObjects )
96 : : //
97 : : : ScSimpleUndo( pNewDocShell ),
98 : : //
99 : : aRange ( rRange ),
100 : : aMarkData ( rMark ),
101 : : pUndoDoc ( pNewUndoDoc ),
102 : : pDrawUndo ( NULL ),
103 : : nFlags ( nNewFlags ),
104 [ + - ]: 8 : bMulti ( bNewMulti ) // ueberliquid
105 : : {
106 [ + + ]: 8 : if (bObjects)
107 [ + - ]: 3 : pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
108 : :
109 [ + - ][ - + ]: 8 : if ( !(aMarkData.IsMarked() || aMarkData.IsMultiMarked()) ) // keine Zelle markiert:
[ - + ]
110 [ # # ]: 0 : aMarkData.SetMarkArea( aRange ); // Zelle unter Cursor markieren
111 : :
112 [ + - ]: 8 : SetChangeTrack();
113 : 8 : }
114 : :
115 : :
116 : : //----------------------------------------------------------------------------
117 : :
118 [ + - ]: 8 : ScUndoDeleteContents::~ScUndoDeleteContents()
119 : : {
120 [ + - ][ + - ]: 8 : delete pUndoDoc;
121 [ + - ]: 8 : DeleteSdrUndoAction( pDrawUndo );
122 [ - + ]: 16 : }
123 : :
124 : :
125 : : //----------------------------------------------------------------------------
126 : :
127 : 8 : rtl::OUString ScUndoDeleteContents::GetComment() const
128 : : {
129 : 8 : return ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS ); // "Loeschen"
130 : : }
131 : :
132 : :
133 : 8 : void ScUndoDeleteContents::SetChangeTrack()
134 : : {
135 : 8 : ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
136 [ # # ][ - + ]: 8 : if ( pChangeTrack && (nFlags & IDF_CONTENTS) )
137 : : pChangeTrack->AppendContentRange( aRange, pUndoDoc,
138 : 0 : nStartChangeAction, nEndChangeAction );
139 : : else
140 : 8 : nStartChangeAction = nEndChangeAction = 0;
141 : 8 : }
142 : :
143 : :
144 : : //----------------------------------------------------------------------------
145 : :
146 : 0 : void ScUndoDeleteContents::DoChange( const sal_Bool bUndo )
147 : : {
148 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
149 : :
150 [ # # ]: 0 : SetViewMarkData( aMarkData );
151 : :
152 : 0 : sal_uInt16 nExtFlags = 0;
153 : :
154 [ # # ]: 0 : if (bUndo) // nur Undo
155 : : {
156 : 0 : sal_uInt16 nUndoFlags = IDF_NONE; // entweder alle oder keine Inhalte kopieren
157 [ # # ]: 0 : if (nFlags & IDF_CONTENTS) // (es sind nur die richtigen ins UndoDoc kopiert worden)
158 : 0 : nUndoFlags |= IDF_CONTENTS;
159 [ # # ]: 0 : if (nFlags & IDF_ATTRIB)
160 : 0 : nUndoFlags |= IDF_ATTRIB;
161 [ # # ]: 0 : if (nFlags & IDF_EDITATTR) // Edit-Engine-Attribute
162 : 0 : nUndoFlags |= IDF_STRING; // -> Zellen werden geaendert
163 : : // do not create clones of note captions, they will be restored via drawing undo
164 : 0 : nUndoFlags |= IDF_NOCAPTIONS;
165 : :
166 : 0 : ScRange aCopyRange = aRange;
167 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
168 : 0 : aCopyRange.aStart.SetTab(0);
169 : 0 : aCopyRange.aEnd.SetTab(nTabCount-1);
170 : :
171 [ # # ]: 0 : pUndoDoc->CopyToDocument( aCopyRange, nUndoFlags, bMulti, pDoc, &aMarkData );
172 : :
173 [ # # ]: 0 : DoSdrUndoAction( pDrawUndo, pDoc );
174 : :
175 : 0 : ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
176 [ # # ]: 0 : if ( pChangeTrack )
177 [ # # ]: 0 : pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
178 : :
179 [ # # ]: 0 : pDocShell->UpdatePaintExt( nExtFlags, aRange ); // content after the change
180 : : }
181 : : else // nur Redo
182 : : {
183 [ # # ]: 0 : pDocShell->UpdatePaintExt( nExtFlags, aRange ); // content before the change
184 : :
185 [ # # ]: 0 : aMarkData.MarkToMulti();
186 [ # # ]: 0 : RedoSdrUndoAction( pDrawUndo );
187 : : // do not delete objects and note captions, they have been removed via drawing undo
188 : 0 : sal_uInt16 nRedoFlags = (nFlags & ~IDF_OBJECTS) | IDF_NOCAPTIONS;
189 [ # # ]: 0 : pDoc->DeleteSelection( nRedoFlags, aMarkData );
190 [ # # ]: 0 : aMarkData.MarkToSimple();
191 : :
192 [ # # ]: 0 : SetChangeTrack();
193 : : }
194 : :
195 [ # # ]: 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
196 [ # # ]: 0 : if ( !( (pViewShell) && pViewShell->AdjustRowHeight(
197 [ # # ][ # # ]: 0 : aRange.aStart.Row(), aRange.aEnd.Row() ) ) )
[ # # ]
198 [ # # ][ # # ]: 0 : /*A*/ pDocShell->PostPaint( aRange, PAINT_GRID | PAINT_EXTRAS, nExtFlags );
[ # # ]
199 : :
200 [ # # ]: 0 : pDocShell->PostDataChanged();
201 [ # # ]: 0 : if (pViewShell)
202 [ # # ]: 0 : pViewShell->CellContentChanged();
203 : :
204 [ # # ]: 0 : ShowTable( aRange );
205 : 0 : }
206 : :
207 : :
208 : : //----------------------------------------------------------------------------
209 : :
210 : 0 : void ScUndoDeleteContents::Undo()
211 : : {
212 : 0 : BeginUndo();
213 : 0 : DoChange( sal_True );
214 : 0 : EndUndo();
215 : :
216 : : // #i97876# Spreadsheet data changes are not notified
217 [ # # ]: 0 : ScModelObj* pModelObj = ScModelObj::getImplementation( pDocShell->GetModel() );
218 [ # # ][ # # ]: 0 : if ( pModelObj && pModelObj->HasChangesListeners() )
[ # # ]
219 : : {
220 [ # # ]: 0 : ScRangeList aChangeRanges;
221 [ # # ]: 0 : aChangeRanges.Append( aRange );
222 [ # # ][ # # ]: 0 : pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
[ # # ][ # # ]
[ # # ]
223 : : }
224 : 0 : }
225 : :
226 : :
227 : : //----------------------------------------------------------------------------
228 : :
229 : 0 : void ScUndoDeleteContents::Redo()
230 : : {
231 : 0 : BeginRedo();
232 : 0 : DoChange( false );
233 : 0 : EndRedo();
234 : :
235 : : // #i97876# Spreadsheet data changes are not notified
236 [ # # ]: 0 : ScModelObj* pModelObj = ScModelObj::getImplementation( pDocShell->GetModel() );
237 [ # # ][ # # ]: 0 : if ( pModelObj && pModelObj->HasChangesListeners() )
[ # # ]
238 : : {
239 [ # # ]: 0 : ScRangeList aChangeRanges;
240 [ # # ]: 0 : aChangeRanges.Append( aRange );
241 [ # # ][ # # ]: 0 : pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
[ # # ][ # # ]
[ # # ]
242 : : }
243 : 0 : }
244 : :
245 : :
246 : : //----------------------------------------------------------------------------
247 : :
248 : 0 : void ScUndoDeleteContents::Repeat(SfxRepeatTarget& rTarget)
249 : : {
250 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
251 : 0 : ((ScTabViewTarget&)rTarget).GetViewShell()->DeleteContents( nFlags, sal_True );
252 : 0 : }
253 : :
254 : :
255 : : //----------------------------------------------------------------------------
256 : :
257 : 0 : sal_Bool ScUndoDeleteContents::CanRepeat(SfxRepeatTarget& rTarget) const
258 : : {
259 : 0 : return (rTarget.ISA(ScTabViewTarget));
260 : : }
261 : :
262 : :
263 : : //============================================================================
264 : : // class ScUndoFillTable
265 : : //
266 : : // Tabellen ausfuellen
267 : : // (Bearbeiten|Ausfuellen|...)
268 : :
269 : : //----------------------------------------------------------------------------
270 : :
271 : 0 : ScUndoFillTable::ScUndoFillTable( ScDocShell* pNewDocShell,
272 : : const ScMarkData& rMark,
273 : : SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
274 : : SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
275 : : ScDocument* pNewUndoDoc, sal_Bool bNewMulti, SCTAB nSrc,
276 : : sal_uInt16 nFlg, sal_uInt16 nFunc, sal_Bool bSkip, sal_Bool bLink )
277 : : //
278 : : : ScSimpleUndo( pNewDocShell ),
279 : : //
280 : : aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ),
281 : : aMarkData ( rMark ),
282 : : pUndoDoc ( pNewUndoDoc ),
283 : : nFlags ( nFlg ),
284 : : nFunction ( nFunc ),
285 : : nSrcTab ( nSrc ),
286 : : bMulti ( bNewMulti ),
287 : : bSkipEmpty ( bSkip ),
288 [ # # ]: 0 : bAsLink ( bLink )
289 : : {
290 [ # # ]: 0 : SetChangeTrack();
291 : 0 : }
292 : :
293 : :
294 : : //----------------------------------------------------------------------------
295 : :
296 [ # # ]: 0 : ScUndoFillTable::~ScUndoFillTable()
297 : : {
298 [ # # ][ # # ]: 0 : delete pUndoDoc;
299 [ # # ]: 0 : }
300 : :
301 : :
302 : : //----------------------------------------------------------------------------
303 : :
304 : 0 : rtl::OUString ScUndoFillTable::GetComment() const
305 : : {
306 : 0 : return ScGlobal::GetRscString( STR_FILL_TAB );
307 : : }
308 : :
309 : :
310 : 0 : void ScUndoFillTable::SetChangeTrack()
311 : : {
312 : 0 : ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
313 [ # # ]: 0 : if ( pChangeTrack )
314 : : {
315 [ # # ]: 0 : SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount();
316 : 0 : ScRange aWorkRange(aRange);
317 : 0 : nStartChangeAction = 0;
318 : : sal_uLong nTmpAction;
319 [ # # ][ # # ]: 0 : ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end();
320 [ # # ][ # # ]: 0 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ # # ][ # # ]
[ # # ][ # # ]
321 : : {
322 [ # # ][ # # ]: 0 : if (*itr != nSrcTab)
323 : : {
324 [ # # ]: 0 : aWorkRange.aStart.SetTab(*itr);
325 [ # # ]: 0 : aWorkRange.aEnd.SetTab(*itr);
326 : : pChangeTrack->AppendContentRange( aWorkRange, pUndoDoc,
327 [ # # ]: 0 : nTmpAction, nEndChangeAction );
328 [ # # ]: 0 : if ( !nStartChangeAction )
329 : 0 : nStartChangeAction = nTmpAction;
330 : : }
331 : : }
332 : : }
333 : : else
334 : 0 : nStartChangeAction = nEndChangeAction = 0;
335 : 0 : }
336 : :
337 : :
338 : : //----------------------------------------------------------------------------
339 : :
340 : 0 : void ScUndoFillTable::DoChange( const sal_Bool bUndo )
341 : : {
342 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
343 : :
344 : 0 : SetViewMarkData( aMarkData );
345 : :
346 [ # # ]: 0 : if (bUndo) // nur Undo
347 : : {
348 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
349 : 0 : ScRange aWorkRange(aRange);
350 [ # # ][ # # ]: 0 : ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end();
351 [ # # ][ # # ]: 0 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ # # ][ # # ]
[ # # ][ # # ]
352 [ # # ][ # # ]: 0 : if (*itr != nSrcTab)
353 : : {
354 [ # # ]: 0 : aWorkRange.aStart.SetTab(*itr);
355 [ # # ]: 0 : aWorkRange.aEnd.SetTab(*itr);
356 [ # # ]: 0 : if (bMulti)
357 [ # # ][ # # ]: 0 : pDoc->DeleteSelectionTab( *itr, IDF_ALL, aMarkData );
358 : : else
359 [ # # ]: 0 : pDoc->DeleteAreaTab( aWorkRange, IDF_ALL );
360 [ # # ]: 0 : pUndoDoc->CopyToDocument( aWorkRange, IDF_ALL, bMulti, pDoc, &aMarkData );
361 : : }
362 : :
363 : 0 : ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
364 [ # # ]: 0 : if ( pChangeTrack )
365 [ # # ]: 0 : pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
366 : : }
367 : : else // nur Redo
368 : : {
369 : 0 : aMarkData.MarkToMulti();
370 : 0 : pDoc->FillTabMarked( nSrcTab, aMarkData, nFlags, nFunction, bSkipEmpty, bAsLink );
371 : 0 : aMarkData.MarkToSimple();
372 : 0 : SetChangeTrack();
373 : : }
374 : :
375 : 0 : pDocShell->PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_EXTRAS);
376 : 0 : pDocShell->PostDataChanged();
377 : :
378 : : // CellContentChanged kommt mit der Markierung
379 : :
380 : 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
381 [ # # ]: 0 : if (pViewShell)
382 : : {
383 : 0 : SCTAB nTab = pViewShell->GetViewData()->GetTabNo();
384 [ # # ]: 0 : if ( !aMarkData.GetTableSelect(nTab) )
385 : 0 : pViewShell->SetTabNo( nSrcTab );
386 : :
387 : 0 : pViewShell->DoneBlockMode(); // gibt sonst Probleme, weil Markierung auf falscher Tabelle
388 : : }
389 : 0 : }
390 : :
391 : :
392 : : //----------------------------------------------------------------------------
393 : :
394 : 0 : void ScUndoFillTable::Undo()
395 : : {
396 : 0 : BeginUndo();
397 : 0 : DoChange( sal_True );
398 : 0 : EndUndo();
399 : 0 : }
400 : :
401 : :
402 : : //----------------------------------------------------------------------------
403 : :
404 : 0 : void ScUndoFillTable::Redo()
405 : : {
406 : 0 : BeginRedo();
407 : 0 : DoChange( false );
408 : 0 : EndRedo();
409 : 0 : }
410 : :
411 : :
412 : : //----------------------------------------------------------------------------
413 : :
414 : 0 : void ScUndoFillTable::Repeat(SfxRepeatTarget& rTarget)
415 : : {
416 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
417 : 0 : ((ScTabViewTarget&)rTarget).GetViewShell()->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink );
418 : 0 : }
419 : :
420 : :
421 : : //----------------------------------------------------------------------------
422 : :
423 : 0 : sal_Bool ScUndoFillTable::CanRepeat(SfxRepeatTarget& rTarget) const
424 : : {
425 : 0 : return (rTarget.ISA(ScTabViewTarget));
426 : : }
427 : :
428 : :
429 : : //============================================================================
430 : : // class ScUndoSelectionAttr
431 : : //
432 : : // Zellformat aendern
433 : :
434 : : //----------------------------------------------------------------------------
435 : :
436 : 606 : ScUndoSelectionAttr::ScUndoSelectionAttr( ScDocShell* pNewDocShell,
437 : : const ScMarkData& rMark,
438 : : SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
439 : : SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
440 : : ScDocument* pNewUndoDoc, sal_Bool bNewMulti,
441 : : const ScPatternAttr* pNewApply,
442 : : const SvxBoxItem* pNewOuter, const SvxBoxInfoItem* pNewInner )
443 : : //
444 : : : ScSimpleUndo( pNewDocShell ),
445 : : //
446 : : aMarkData ( rMark ),
447 : : aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ),
448 : : pUndoDoc ( pNewUndoDoc ),
449 [ + - ][ + - ]: 606 : bMulti ( bNewMulti )
450 : : {
451 [ + - ]: 606 : ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
452 [ + - ]: 606 : pApplyPattern = (ScPatternAttr*) &pPool->Put( *pNewApply );
453 [ - + ][ # # ]: 606 : pLineOuter = pNewOuter ? (SvxBoxItem*) &pPool->Put( *pNewOuter ) : NULL;
454 [ - + ][ # # ]: 606 : pLineInner = pNewInner ? (SvxBoxInfoItem*) &pPool->Put( *pNewInner ) : NULL;
455 : 606 : }
456 : :
457 : :
458 : : //----------------------------------------------------------------------------
459 : :
460 [ + - ][ + - ]: 606 : ScUndoSelectionAttr::~ScUndoSelectionAttr()
461 : : {
462 [ + - ]: 606 : ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
463 [ + - ]: 606 : pPool->Remove(*pApplyPattern);
464 [ - + ]: 606 : if (pLineOuter)
465 [ # # ]: 0 : pPool->Remove(*pLineOuter);
466 [ - + ]: 606 : if (pLineInner)
467 [ # # ]: 0 : pPool->Remove(*pLineInner);
468 : :
469 [ + - ][ + - ]: 606 : delete pUndoDoc;
470 [ - + ]: 1212 : }
471 : :
472 : :
473 : : //----------------------------------------------------------------------------
474 : :
475 : 786 : rtl::OUString ScUndoSelectionAttr::GetComment() const
476 : : {
477 : : //"Attribute" "/Linien"
478 [ - + ]: 786 : return ScGlobal::GetRscString( pLineOuter ? STR_UNDO_SELATTRLINES : STR_UNDO_SELATTR );
479 : : }
480 : :
481 : : //----------------------------------------------------------------------------
482 : :
483 : 0 : ScEditDataArray* ScUndoSelectionAttr::GetDataArray()
484 : : {
485 : 0 : return &aDataArray;
486 : : }
487 : :
488 : : //----------------------------------------------------------------------------
489 : :
490 : 0 : void ScUndoSelectionAttr::DoChange( const sal_Bool bUndo )
491 : : {
492 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
493 : :
494 [ # # ]: 0 : SetViewMarkData( aMarkData );
495 : :
496 : 0 : ScRange aEffRange( aRange );
497 [ # # ][ # # ]: 0 : if ( pDoc->HasAttrib( aEffRange, HASATTR_MERGED ) ) // zusammengefasste Zellen?
498 [ # # ]: 0 : pDoc->ExtendMerge( aEffRange );
499 : :
500 : 0 : sal_uInt16 nExtFlags = 0;
501 [ # # ]: 0 : pDocShell->UpdatePaintExt( nExtFlags, aEffRange );
502 : :
503 [ # # ]: 0 : ChangeEditData(bUndo);
504 : :
505 [ # # ]: 0 : if (bUndo) // nur bei Undo
506 : : {
507 : 0 : ScRange aCopyRange = aRange;
508 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
509 : 0 : aCopyRange.aStart.SetTab(0);
510 : 0 : aCopyRange.aEnd.SetTab(nTabCount-1);
511 [ # # ]: 0 : pUndoDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, bMulti, pDoc, &aMarkData );
512 : : }
513 : : else // nur bei Redo
514 : : {
515 [ # # ]: 0 : aMarkData.MarkToMulti();
516 [ # # ]: 0 : pDoc->ApplySelectionPattern( *pApplyPattern, aMarkData );
517 [ # # ]: 0 : aMarkData.MarkToSimple();
518 : :
519 [ # # ]: 0 : if (pLineOuter)
520 [ # # ]: 0 : pDoc->ApplySelectionFrame( aMarkData, pLineOuter, pLineInner );
521 : : }
522 : :
523 [ # # ]: 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
524 [ # # ][ # # ]: 0 : if ( !( (pViewShell) && pViewShell->AdjustBlockHeight() ) )
[ # # ][ # # ]
525 [ # # ][ # # ]: 0 : /*A*/ pDocShell->PostPaint( aEffRange, PAINT_GRID | PAINT_EXTRAS, nExtFlags );
[ # # ]
526 : :
527 [ # # ]: 0 : ShowTable( aRange );
528 : 0 : }
529 : :
530 : 0 : void ScUndoSelectionAttr::ChangeEditData( const bool bUndo )
531 : : {
532 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
533 [ # # ]: 0 : for (const ScEditDataArray::Item* pItem = aDataArray.First(); pItem; pItem = aDataArray.Next())
534 : : {
535 : : ScBaseCell* pCell;
536 [ # # ][ # # ]: 0 : pDoc->GetCell(pItem->GetCol(), pItem->GetRow(), pItem->GetTab(), pCell);
[ # # ][ # # ]
537 [ # # ][ # # ]: 0 : if (!pCell || pCell->GetCellType() != CELLTYPE_EDIT)
[ # # ]
538 : 0 : continue;
539 : :
540 : 0 : ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
541 [ # # ]: 0 : if (bUndo)
542 [ # # ][ # # ]: 0 : pEditCell->SetData(pItem->GetOldData(), NULL);
543 : : else
544 [ # # ][ # # ]: 0 : pEditCell->SetData(pItem->GetNewData(), NULL);
545 : : }
546 : 0 : }
547 : :
548 : :
549 : : //----------------------------------------------------------------------------
550 : :
551 : 0 : void ScUndoSelectionAttr::Undo()
552 : : {
553 : 0 : BeginUndo();
554 : 0 : DoChange( sal_True );
555 : 0 : EndUndo();
556 : 0 : }
557 : :
558 : :
559 : : //----------------------------------------------------------------------------
560 : :
561 : 0 : void ScUndoSelectionAttr::Redo()
562 : : {
563 : 0 : BeginRedo();
564 : 0 : DoChange( false );
565 : 0 : EndRedo();
566 : 0 : }
567 : :
568 : :
569 : : //----------------------------------------------------------------------------
570 : :
571 : 0 : void ScUndoSelectionAttr::Repeat(SfxRepeatTarget& rTarget)
572 : : {
573 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
574 : : {
575 : 0 : ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
576 [ # # ]: 0 : if (pLineOuter)
577 : 0 : rViewShell.ApplyPatternLines( *pApplyPattern, pLineOuter, pLineInner, sal_True );
578 : : else
579 : 0 : rViewShell.ApplySelectionPattern( *pApplyPattern, sal_True );
580 : : }
581 : 0 : }
582 : :
583 : :
584 : : //----------------------------------------------------------------------------
585 : :
586 : 90 : sal_Bool ScUndoSelectionAttr::CanRepeat(SfxRepeatTarget& rTarget) const
587 : : {
588 : 90 : return (rTarget.ISA(ScTabViewTarget));
589 : : }
590 : :
591 : :
592 : : //============================================================================
593 : : // class ScUndoAutoFill
594 : : //
595 : : // Auto-Fill (nur einfache Bloecke)
596 : :
597 : : //----------------------------------------------------------------------------
598 : :
599 : 12 : ScUndoAutoFill::ScUndoAutoFill( ScDocShell* pNewDocShell,
600 : : const ScRange& rRange, const ScRange& rSourceArea,
601 : : ScDocument* pNewUndoDoc, const ScMarkData& rMark,
602 : : FillDir eNewFillDir, FillCmd eNewFillCmd, FillDateCmd eNewFillDateCmd,
603 : : double fNewStartValue, double fNewStepValue, double fNewMaxValue )
604 : : //
605 : : : ScBlockUndo( pNewDocShell, rRange, SC_UNDO_AUTOHEIGHT ),
606 : : //
607 : : aSource ( rSourceArea ),
608 : : aMarkData ( rMark ),
609 : : pUndoDoc ( pNewUndoDoc ),
610 : : eFillDir ( eNewFillDir ),
611 : : eFillCmd ( eNewFillCmd ),
612 : : eFillDateCmd ( eNewFillDateCmd ),
613 : : fStartValue ( fNewStartValue ),
614 : : fStepValue ( fNewStepValue ),
615 [ + - ]: 12 : fMaxValue ( fNewMaxValue )
616 : : {
617 [ + - ]: 12 : SetChangeTrack();
618 : 12 : }
619 : :
620 : :
621 : : //----------------------------------------------------------------------------
622 : :
623 [ + - ]: 12 : ScUndoAutoFill::~ScUndoAutoFill()
624 : : {
625 [ + - ][ + - ]: 12 : delete pUndoDoc;
626 [ - + ]: 24 : }
627 : :
628 : :
629 : : //----------------------------------------------------------------------------
630 : :
631 : 12 : rtl::OUString ScUndoAutoFill::GetComment() const
632 : : {
633 : 12 : return ScGlobal::GetRscString( STR_UNDO_AUTOFILL ); //"Ausfuellen"
634 : : }
635 : :
636 : :
637 : 12 : void ScUndoAutoFill::SetChangeTrack()
638 : : {
639 : 12 : ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
640 [ - + ]: 12 : if ( pChangeTrack )
641 : : pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc,
642 : 0 : nStartChangeAction, nEndChangeAction );
643 : : else
644 : 12 : nStartChangeAction = nEndChangeAction = 0;
645 : 12 : }
646 : :
647 : 0 : void ScUndoAutoFill::Undo()
648 : : {
649 [ # # ]: 0 : BeginUndo();
650 : :
651 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
652 : :
653 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
654 [ # # ][ # # ]: 0 : ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end();
655 [ # # ][ # # ]: 0 : for (; itr != itrEnd && *itr < nTabCount; ++itr)
[ # # ][ # # ]
[ # # ][ # # ]
656 : : {
657 : 0 : ScRange aWorkRange = aBlockRange;
658 [ # # ]: 0 : aWorkRange.aStart.SetTab(*itr);
659 [ # # ]: 0 : aWorkRange.aEnd.SetTab(*itr);
660 : :
661 : 0 : sal_uInt16 nExtFlags = 0;
662 [ # # ]: 0 : pDocShell->UpdatePaintExt( nExtFlags, aWorkRange );
663 [ # # ]: 0 : pDoc->DeleteAreaTab( aWorkRange, IDF_AUTOFILL );
664 [ # # ]: 0 : pUndoDoc->CopyToDocument( aWorkRange, IDF_AUTOFILL, false, pDoc );
665 : :
666 [ # # ]: 0 : pDoc->ExtendMerge( aWorkRange, sal_True );
667 [ # # ][ # # ]: 0 : pDocShell->PostPaint( aWorkRange, PAINT_GRID, nExtFlags );
[ # # ]
668 : : }
669 [ # # ]: 0 : pDocShell->PostDataChanged();
670 [ # # ]: 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
671 [ # # ]: 0 : if (pViewShell)
672 [ # # ]: 0 : pViewShell->CellContentChanged();
673 : :
674 : 0 : ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
675 [ # # ]: 0 : if ( pChangeTrack )
676 [ # # ]: 0 : pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
677 : :
678 [ # # ]: 0 : EndUndo();
679 : 0 : }
680 : :
681 : :
682 : : //----------------------------------------------------------------------------
683 : :
684 : 0 : void ScUndoAutoFill::Redo()
685 : : {
686 [ # # ]: 0 : BeginRedo();
687 : :
688 : : //! Tabellen selektieren
689 : :
690 : 0 : SCCOLROW nCount = 0;
691 [ # # # # : 0 : switch (eFillDir)
# ]
692 : : {
693 : : case FILL_TO_BOTTOM:
694 : 0 : nCount = aBlockRange.aEnd.Row() - aSource.aEnd.Row();
695 : 0 : break;
696 : : case FILL_TO_RIGHT:
697 : 0 : nCount = aBlockRange.aEnd.Col() - aSource.aEnd.Col();
698 : 0 : break;
699 : : case FILL_TO_TOP:
700 : 0 : nCount = aSource.aStart.Row() - aBlockRange.aStart.Row();
701 : 0 : break;
702 : : case FILL_TO_LEFT:
703 : 0 : nCount = aSource.aStart.Col() - aBlockRange.aStart.Col();
704 : 0 : break;
705 : : }
706 : :
707 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
708 [ # # ]: 0 : if ( fStartValue != MAXDOUBLE )
709 : : {
710 [ # # ]: 0 : SCCOL nValX = (eFillDir == FILL_TO_LEFT) ? aSource.aEnd.Col() : aSource.aStart.Col();
711 [ # # ]: 0 : SCROW nValY = (eFillDir == FILL_TO_TOP ) ? aSource.aEnd.Row() : aSource.aStart.Row();
712 : 0 : SCTAB nTab = aSource.aStart.Tab();
713 [ # # ]: 0 : pDoc->SetValue( nValX, nValY, nTab, fStartValue );
714 : : }
715 : : sal_uLong nProgCount;
716 [ # # ][ # # ]: 0 : if (eFillDir == FILL_TO_BOTTOM || eFillDir == FILL_TO_TOP)
717 : 0 : nProgCount = aSource.aEnd.Col() - aSource.aStart.Col() + 1;
718 : : else
719 : 0 : nProgCount = aSource.aEnd.Row() - aSource.aStart.Row() + 1;
720 : 0 : nProgCount *= nCount;
721 : : ScProgress aProgress( pDoc->GetDocumentShell(),
722 [ # # ][ # # ]: 0 : ScGlobal::GetRscString(STR_FILL_SERIES_PROGRESS), nProgCount );
723 : :
724 : 0 : pDoc->Fill( aSource.aStart.Col(), aSource.aStart.Row(),
725 : 0 : aSource.aEnd.Col(), aSource.aEnd.Row(), &aProgress,
726 : : aMarkData, nCount,
727 : : eFillDir, eFillCmd, eFillDateCmd,
728 [ # # ]: 0 : fStepValue, fMaxValue );
729 : :
730 [ # # ]: 0 : SetChangeTrack();
731 : :
732 [ # # ][ # # ]: 0 : pDocShell->PostPaint( aBlockRange, PAINT_GRID );
[ # # ]
733 [ # # ]: 0 : pDocShell->PostDataChanged();
734 [ # # ]: 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
735 [ # # ]: 0 : if (pViewShell)
736 [ # # ]: 0 : pViewShell->CellContentChanged();
737 : :
738 [ # # ][ # # ]: 0 : EndRedo();
739 : 0 : }
740 : :
741 : :
742 : : //----------------------------------------------------------------------------
743 : :
744 : 0 : void ScUndoAutoFill::Repeat(SfxRepeatTarget& rTarget)
745 : : {
746 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
747 : : {
748 : 0 : ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
749 [ # # ]: 0 : if (eFillCmd==FILL_SIMPLE)
750 : 0 : rViewShell.FillSimple( eFillDir, sal_True );
751 : : else
752 : : rViewShell.FillSeries( eFillDir, eFillCmd, eFillDateCmd,
753 : 0 : fStartValue, fStepValue, fMaxValue, sal_True );
754 : : }
755 : 0 : }
756 : :
757 : :
758 : : //----------------------------------------------------------------------------
759 : :
760 : 0 : sal_Bool ScUndoAutoFill::CanRepeat(SfxRepeatTarget& rTarget) const
761 : : {
762 : 0 : return (rTarget.ISA(ScTabViewTarget));
763 : : }
764 : :
765 : :
766 : : //============================================================================
767 : : // class ScUndoMerge
768 : : //
769 : : // Zellen zusammenfassen / Zusammenfassung aufheben
770 : :
771 : : //----------------------------------------------------------------------------
772 : :
773 : 6 : ScUndoMerge::ScUndoMerge( ScDocShell* pNewDocShell, const ScCellMergeOption& rOption,
774 : : bool bMergeContents, ScDocument* pUndoDoc, SdrUndoAction* pDrawUndo )
775 : : //
776 : : : ScSimpleUndo( pNewDocShell ),
777 : : //
778 : : maOption(rOption),
779 : : mbMergeContents( bMergeContents ),
780 : : mpUndoDoc( pUndoDoc ),
781 [ + - ]: 6 : mpDrawUndo( pDrawUndo )
782 : : {
783 : 6 : }
784 : :
785 : :
786 : : //----------------------------------------------------------------------------
787 : :
788 : 3 : ScUndoMerge::~ScUndoMerge()
789 : : {
790 [ + - ][ + - ]: 3 : delete mpUndoDoc;
791 [ + - ]: 3 : DeleteSdrUndoAction( mpDrawUndo );
792 [ - + ]: 6 : }
793 : :
794 : :
795 : : //----------------------------------------------------------------------------
796 : :
797 : 10 : rtl::OUString ScUndoMerge::GetComment() const
798 : : {
799 : 10 : return ScGlobal::GetRscString( STR_UNDO_MERGE );
800 : : }
801 : :
802 : :
803 : : //----------------------------------------------------------------------------
804 : :
805 : 0 : void ScUndoMerge::DoChange( bool bUndo ) const
806 : : {
807 : : using ::std::set;
808 : :
809 [ # # ]: 0 : if (maOption.maTabs.empty())
810 : : // Nothing to do.
811 : 0 : return;
812 : :
813 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
814 [ # # ]: 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
815 : :
816 [ # # ][ # # ]: 0 : ScRange aCurRange = maOption.getSingleRange(pDocShell->GetCurTab());
817 [ # # ]: 0 : ScUndoUtil::MarkSimpleBlock(pDocShell, aCurRange);
818 : :
819 [ # # ][ # # ]: 0 : for (set<SCTAB>::const_iterator itr = maOption.maTabs.begin(), itrEnd = maOption.maTabs.end();
[ # # ]
820 : : itr != itrEnd; ++itr)
821 : : {
822 [ # # ]: 0 : SCTAB nTab = *itr;
823 [ # # ]: 0 : ScRange aRange = maOption.getSingleRange(nTab);
824 : :
825 [ # # ]: 0 : if (bUndo)
826 : : // remove merge (contents are copied back below from undo document)
827 [ # # ]: 0 : pDoc->RemoveMerge( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab() );
828 : : else
829 : : {
830 : : // repeat merge, but do not remove note captions (will be done by drawing redo below)
831 : 0 : pDoc->DoMerge( aRange.aStart.Tab(),
832 : 0 : aRange.aStart.Col(), aRange.aStart.Row(),
833 [ # # ]: 0 : aRange.aEnd.Col(), aRange.aEnd.Row(), false );
834 : :
835 [ # # ]: 0 : if (maOption.mbCenter)
836 : : {
837 : 0 : pDoc->ApplyAttr( aRange.aStart.Col(), aRange.aStart.Row(),
838 : 0 : aRange.aStart.Tab(),
839 [ # # # # ]: 0 : SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ) );
[ # # ]
840 : 0 : pDoc->ApplyAttr( aRange.aStart.Col(), aRange.aStart.Row(),
841 : 0 : aRange.aStart.Tab(),
842 [ # # # # ]: 0 : SvxVerJustifyItem( SVX_VER_JUSTIFY_CENTER, ATTR_VER_JUSTIFY ) );
[ # # ]
843 : : }
844 : : }
845 : :
846 : : // undo -> copy back deleted contents
847 [ # # ][ # # ]: 0 : if (bUndo && mpUndoDoc)
848 : : {
849 [ # # ]: 0 : pDoc->DeleteAreaTab( aRange, IDF_CONTENTS|IDF_NOCAPTIONS );
850 [ # # ]: 0 : mpUndoDoc->CopyToDocument( aRange, IDF_ALL|IDF_NOCAPTIONS, false, pDoc );
851 : : }
852 : :
853 : : // redo -> merge contents again
854 [ # # ][ # # ]: 0 : else if (!bUndo && mbMergeContents)
855 : : {
856 : 0 : pDoc->DoMergeContents( aRange.aStart.Tab(),
857 : 0 : aRange.aStart.Col(), aRange.aStart.Row(),
858 [ # # ]: 0 : aRange.aEnd.Col(), aRange.aEnd.Row() );
859 : : }
860 : :
861 [ # # ]: 0 : if (bUndo)
862 [ # # ]: 0 : DoSdrUndoAction( mpDrawUndo, pDoc );
863 : : else
864 [ # # ]: 0 : RedoSdrUndoAction( mpDrawUndo );
865 : :
866 : 0 : bool bDidPaint = false;
867 [ # # ]: 0 : if ( pViewShell )
868 : : {
869 [ # # ]: 0 : pViewShell->SetTabNo(nTab);
870 [ # # ]: 0 : bDidPaint = pViewShell->AdjustRowHeight(maOption.mnStartRow, maOption.mnEndRow);
871 : : }
872 : :
873 [ # # ]: 0 : if (!bDidPaint)
874 [ # # ]: 0 : ScUndoUtil::PaintMore(pDocShell, aRange);
875 : : }
876 : :
877 [ # # ]: 0 : ShowTable(aCurRange);
878 : : }
879 : :
880 : :
881 : : //----------------------------------------------------------------------------
882 : :
883 : 0 : void ScUndoMerge::Undo()
884 : : {
885 : 0 : BeginUndo();
886 : 0 : DoChange( true );
887 : 0 : EndUndo();
888 : 0 : }
889 : :
890 : :
891 : : //----------------------------------------------------------------------------
892 : :
893 : 0 : void ScUndoMerge::Redo()
894 : : {
895 : 0 : BeginRedo();
896 : 0 : DoChange( false );
897 : 0 : EndRedo();
898 : 0 : }
899 : :
900 : :
901 : : //----------------------------------------------------------------------------
902 : :
903 : 0 : void ScUndoMerge::Repeat(SfxRepeatTarget& rTarget)
904 : : {
905 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
906 : : {
907 : 0 : ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
908 : 0 : sal_Bool bCont = false;
909 [ # # ]: 0 : rViewShell.MergeCells( false, bCont, sal_True );
910 : : }
911 : 0 : }
912 : :
913 : :
914 : : //----------------------------------------------------------------------------
915 : :
916 : 2 : sal_Bool ScUndoMerge::CanRepeat(SfxRepeatTarget& rTarget) const
917 : : {
918 : 2 : return (rTarget.ISA(ScTabViewTarget));
919 : : }
920 : :
921 : :
922 : : //============================================================================
923 : : // class ScUndoAutoFormat
924 : : //
925 : : // Auto-Format (nur einfache Bloecke)
926 : :
927 : : //----------------------------------------------------------------------------
928 : :
929 : 0 : ScUndoAutoFormat::ScUndoAutoFormat( ScDocShell* pNewDocShell,
930 : : const ScRange& rRange, ScDocument* pNewUndoDoc,
931 : : const ScMarkData& rMark, sal_Bool bNewSize, sal_uInt16 nNewFormatNo )
932 : : //
933 : : : ScBlockUndo( pNewDocShell, rRange, bNewSize ? SC_UNDO_MANUALHEIGHT : SC_UNDO_AUTOHEIGHT ),
934 : : //
935 : : pUndoDoc ( pNewUndoDoc ),
936 : : aMarkData ( rMark ),
937 : : bSize ( bNewSize ),
938 [ # # ][ # # ]: 0 : nFormatNo ( nNewFormatNo )
939 : : {
940 : 0 : }
941 : :
942 : :
943 : : //----------------------------------------------------------------------------
944 : :
945 [ # # ]: 0 : ScUndoAutoFormat::~ScUndoAutoFormat()
946 : : {
947 [ # # ][ # # ]: 0 : delete pUndoDoc;
948 [ # # ]: 0 : }
949 : :
950 : :
951 : : //----------------------------------------------------------------------------
952 : :
953 : 0 : rtl::OUString ScUndoAutoFormat::GetComment() const
954 : : {
955 : 0 : return ScGlobal::GetRscString( STR_UNDO_AUTOFORMAT ); //"Auto-Format"
956 : : }
957 : :
958 : :
959 : : //----------------------------------------------------------------------------
960 : :
961 : 0 : void ScUndoAutoFormat::Undo()
962 : : {
963 [ # # ]: 0 : BeginUndo();
964 : :
965 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
966 : :
967 : : // Attribute
968 : : // pDoc->DeleteAreaTab( aBlockRange, IDF_ATTRIB );
969 : : // pUndoDoc->CopyToDocument( aBlockRange, IDF_ATTRIB, sal_False, pDoc );
970 : :
971 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
972 : 0 : pDoc->DeleteArea( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(),
973 : 0 : aBlockRange.aEnd.Col(), aBlockRange.aEnd.Row(),
974 [ # # ]: 0 : aMarkData, IDF_ATTRIB );
975 : 0 : ScRange aCopyRange = aBlockRange;
976 : 0 : aCopyRange.aStart.SetTab(0);
977 : 0 : aCopyRange.aEnd.SetTab(nTabCount-1);
978 [ # # ]: 0 : pUndoDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, false, pDoc, &aMarkData );
979 : :
980 : : // Zellhoehen und -breiten (IDF_NONE)
981 [ # # ]: 0 : if (bSize)
982 : : {
983 : 0 : SCCOL nStartX = aBlockRange.aStart.Col();
984 : 0 : SCROW nStartY = aBlockRange.aStart.Row();
985 : 0 : SCTAB nStartZ = aBlockRange.aStart.Tab();
986 : 0 : SCCOL nEndX = aBlockRange.aEnd.Col();
987 : 0 : SCROW nEndY = aBlockRange.aEnd.Row();
988 : 0 : SCTAB nEndZ = aBlockRange.aEnd.Tab();
989 : :
990 : : pUndoDoc->CopyToDocument( nStartX, 0, 0, nEndX, MAXROW, nTabCount-1,
991 [ # # ]: 0 : IDF_NONE, false, pDoc, &aMarkData );
992 : : pUndoDoc->CopyToDocument( 0, nStartY, 0, MAXCOL, nEndY, nTabCount-1,
993 [ # # ]: 0 : IDF_NONE, false, pDoc, &aMarkData );
994 : : pDocShell->PostPaint( 0, 0, nStartZ, MAXCOL, MAXROW, nEndZ,
995 [ # # ]: 0 : PAINT_GRID | PAINT_LEFT | PAINT_TOP, SC_PF_LINES );
996 : : }
997 : : else
998 [ # # ][ # # ]: 0 : pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES );
[ # # ]
999 : :
1000 [ # # ]: 0 : EndUndo();
1001 : 0 : }
1002 : :
1003 : :
1004 : : //----------------------------------------------------------------------------
1005 : :
1006 : 0 : void ScUndoAutoFormat::Redo()
1007 : : {
1008 : 0 : BeginRedo();
1009 : :
1010 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1011 : :
1012 : 0 : SCCOL nStartX = aBlockRange.aStart.Col();
1013 : 0 : SCROW nStartY = aBlockRange.aStart.Row();
1014 : 0 : SCTAB nStartZ = aBlockRange.aStart.Tab();
1015 : 0 : SCCOL nEndX = aBlockRange.aEnd.Col();
1016 : 0 : SCROW nEndY = aBlockRange.aEnd.Row();
1017 : 0 : SCTAB nEndZ = aBlockRange.aEnd.Tab();
1018 : :
1019 : 0 : pDoc->AutoFormat( nStartX, nStartY, nEndX, nEndY, nFormatNo, aMarkData );
1020 : :
1021 [ # # ]: 0 : if (bSize)
1022 : : {
1023 [ # # ]: 0 : VirtualDevice aVirtDev;
1024 [ # # ]: 0 : Fraction aZoomX(1,1);
1025 [ # # ]: 0 : Fraction aZoomY = aZoomX;
1026 : : double nPPTX,nPPTY;
1027 [ # # ]: 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1028 [ # # ]: 0 : if (pViewShell)
1029 : : {
1030 : 0 : ScViewData* pData = pViewShell->GetViewData();
1031 : 0 : nPPTX = pData->GetPPTX();
1032 : 0 : nPPTY = pData->GetPPTY();
1033 [ # # ]: 0 : aZoomX = pData->GetZoomX();
1034 [ # # ]: 0 : aZoomY = pData->GetZoomY();
1035 : : }
1036 : : else
1037 : : {
1038 : : // Zoom auf 100 lassen
1039 : 0 : nPPTX = ScGlobal::nScreenPPTX;
1040 : 0 : nPPTY = ScGlobal::nScreenPPTY;
1041 : : }
1042 : :
1043 : 0 : sal_Bool bFormula = false; //! merken
1044 : :
1045 [ # # ]: 0 : for (SCTAB nTab=nStartZ; nTab<=nEndZ; nTab++)
1046 : : {
1047 [ # # ]: 0 : ScMarkData aDestMark;
1048 [ # # ]: 0 : aDestMark.SelectOneTable( nTab );
1049 [ # # ]: 0 : aDestMark.SetMarkArea( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) );
1050 [ # # ]: 0 : aDestMark.MarkToMulti();
1051 : :
1052 : : // wie SC_SIZE_VISOPT
1053 [ # # ]: 0 : for (SCROW nRow=nStartY; nRow<=nEndY; nRow++)
1054 : : {
1055 [ # # ]: 0 : sal_uInt8 nOld = pDoc->GetRowFlags(nRow,nTab);
1056 [ # # ]: 0 : bool bHidden = pDoc->RowHidden(nRow, nTab);
1057 [ # # ][ # # ]: 0 : if ( !bHidden && ( nOld & CR_MANUALSIZE ) )
1058 [ # # ]: 0 : pDoc->SetRowFlags( nRow, nTab, nOld & ~CR_MANUALSIZE );
1059 : : }
1060 : : pDoc->SetOptimalHeight( nStartY, nEndY, nTab, 0, &aVirtDev,
1061 [ # # ]: 0 : nPPTX, nPPTY, aZoomX, aZoomY, false );
1062 : :
1063 [ # # ]: 0 : for (SCCOL nCol=nStartX; nCol<=nEndX; nCol++)
1064 [ # # ][ # # ]: 0 : if (!pDoc->ColHidden(nCol, nTab))
1065 : : {
1066 : : sal_uInt16 nThisSize = STD_EXTRA_WIDTH + pDoc->GetOptimalColWidth( nCol, nTab,
1067 : : &aVirtDev, nPPTX, nPPTY, aZoomX, aZoomY, bFormula,
1068 [ # # ]: 0 : &aDestMark );
1069 [ # # ]: 0 : pDoc->SetColWidth( nCol, nTab, nThisSize );
1070 [ # # ]: 0 : pDoc->ShowCol( nCol, nTab, sal_True );
1071 : : }
1072 [ # # ]: 0 : }
1073 : :
1074 : : pDocShell->PostPaint( 0, 0, nStartZ,
1075 : : MAXCOL, MAXROW, nEndZ,
1076 [ # # ][ # # ]: 0 : PAINT_GRID | PAINT_LEFT | PAINT_TOP, SC_PF_LINES);
1077 : : }
1078 : : else
1079 [ # # ]: 0 : pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES );
1080 : :
1081 : 0 : EndRedo();
1082 : 0 : }
1083 : :
1084 : :
1085 : : //----------------------------------------------------------------------------
1086 : :
1087 : 0 : void ScUndoAutoFormat::Repeat(SfxRepeatTarget& rTarget)
1088 : : {
1089 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
1090 : 0 : ((ScTabViewTarget&)rTarget).GetViewShell()->AutoFormat( nFormatNo, sal_True );
1091 : 0 : }
1092 : :
1093 : :
1094 : : //----------------------------------------------------------------------------
1095 : :
1096 : 0 : sal_Bool ScUndoAutoFormat::CanRepeat(SfxRepeatTarget& rTarget) const
1097 : : {
1098 : 0 : return (rTarget.ISA(ScTabViewTarget));
1099 : : }
1100 : :
1101 : :
1102 : : //============================================================================
1103 : : // class ScUndoReplace
1104 : : //
1105 : : // Ersetzen
1106 : :
1107 : : //----------------------------------------------------------------------------
1108 : :
1109 : 14 : ScUndoReplace::ScUndoReplace( ScDocShell* pNewDocShell, const ScMarkData& rMark,
1110 : : SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
1111 : : const String& rNewUndoStr, ScDocument* pNewUndoDoc,
1112 : : const SvxSearchItem* pItem )
1113 : : //
1114 : : : ScSimpleUndo( pNewDocShell ),
1115 : : //
1116 : : aCursorPos ( nCurX, nCurY, nCurZ ),
1117 : : aMarkData ( rMark ),
1118 : : aUndoStr ( rNewUndoStr ),
1119 [ + - ][ + - ]: 14 : pUndoDoc ( pNewUndoDoc )
1120 : : {
1121 [ + - ][ + - ]: 14 : pSearchItem = new SvxSearchItem( *pItem );
1122 [ + - ]: 14 : SetChangeTrack();
1123 : 14 : }
1124 : :
1125 : :
1126 : : //----------------------------------------------------------------------------
1127 : :
1128 [ + - ][ + - ]: 10 : ScUndoReplace::~ScUndoReplace()
1129 : : {
1130 [ + - ][ + - ]: 10 : delete pUndoDoc;
1131 [ + - ][ + - ]: 10 : delete pSearchItem;
1132 [ - + ]: 20 : }
1133 : :
1134 : :
1135 : : //----------------------------------------------------------------------------
1136 : :
1137 : 14 : void ScUndoReplace::SetChangeTrack()
1138 : : {
1139 : 14 : ScDocument* pDoc = pDocShell->GetDocument();
1140 : 14 : ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
1141 [ - + ]: 14 : if ( pChangeTrack )
1142 : : {
1143 [ # # ]: 0 : if ( pUndoDoc )
1144 : : { //! im UndoDoc stehen nur die geaenderten Zellen,
1145 : : // deswegen per Iterator moeglich
1146 : : pChangeTrack->AppendContentsIfInRefDoc( pUndoDoc,
1147 : 0 : nStartChangeAction, nEndChangeAction );
1148 : : }
1149 : : else
1150 : : {
1151 : 0 : nStartChangeAction = pChangeTrack->GetActionMax() + 1;
1152 : : ScChangeActionContent* pContent = new ScChangeActionContent(
1153 [ # # ][ # # ]: 0 : ScRange( aCursorPos) );
1154 [ # # ]: 0 : pContent->SetOldValue( aUndoStr, pDoc );
1155 : 0 : pContent->SetNewValue( pDoc->GetCell( aCursorPos ), pDoc );
1156 : 0 : pChangeTrack->Append( pContent );
1157 : 0 : nEndChangeAction = pChangeTrack->GetActionMax();
1158 : : }
1159 : : }
1160 : : else
1161 : 14 : nStartChangeAction = nEndChangeAction = 0;
1162 : 14 : }
1163 : :
1164 : : //----------------------------------------------------------------------------
1165 : :
1166 : 22 : rtl::OUString ScUndoReplace::GetComment() const
1167 : : {
1168 : 22 : return ScGlobal::GetRscString( STR_UNDO_REPLACE ); // "Ersetzen"
1169 : : }
1170 : :
1171 : :
1172 : : //----------------------------------------------------------------------------
1173 : :
1174 : 0 : void ScUndoReplace::Undo()
1175 : : {
1176 : 0 : BeginUndo();
1177 : :
1178 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1179 : 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1180 : :
1181 : 0 : ShowTable( aCursorPos.Tab() );
1182 : :
1183 [ # # ]: 0 : if (pUndoDoc) // nur bei ReplaceAll !!
1184 : : {
1185 : : OSL_ENSURE(pSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL,
1186 : : "ScUndoReplace:: Falscher Modus");
1187 : :
1188 : 0 : SetViewMarkData( aMarkData );
1189 : :
1190 : : //! markierte Tabellen
1191 : : //! Bereich merken ?
1192 : :
1193 : : // Undo-Dokument hat keine Zeilen-/Spalten-Infos, also mit bColRowFlags = FALSE
1194 : : // kopieren, um Outline-Gruppen nicht kaputtzumachen.
1195 : :
1196 [ # # ]: 0 : sal_uInt16 nUndoFlags = (pSearchItem->GetPattern()) ? IDF_ATTRIB : IDF_CONTENTS;
1197 : : pUndoDoc->CopyToDocument( 0, 0, 0,
1198 : : MAXCOL, MAXROW, MAXTAB,
1199 : 0 : nUndoFlags, false, pDoc, NULL, false ); // ohne Row-Flags
1200 : 0 : pDocShell->PostPaintGridAll();
1201 : : }
1202 [ # # # # ]: 0 : else if (pSearchItem->GetPattern() &&
[ # # ]
1203 : 0 : pSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE)
1204 : : {
1205 [ # # ]: 0 : String aTempStr = pSearchItem->GetSearchString(); // vertauschen
1206 [ # # ][ # # ]: 0 : pSearchItem->SetSearchString(pSearchItem->GetReplaceString());
[ # # ]
1207 [ # # ]: 0 : pSearchItem->SetReplaceString(aTempStr);
1208 : : pDoc->ReplaceStyle( *pSearchItem,
1209 : 0 : aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(),
1210 [ # # ]: 0 : aMarkData, sal_True);
1211 [ # # ][ # # ]: 0 : pSearchItem->SetReplaceString(pSearchItem->GetSearchString());
[ # # ]
1212 [ # # ]: 0 : pSearchItem->SetSearchString(aTempStr);
1213 [ # # ]: 0 : if (pViewShell)
1214 : 0 : pViewShell->MoveCursorAbs( aCursorPos.Col(), aCursorPos.Row(),
1215 [ # # ]: 0 : SC_FOLLOW_JUMP, false, false );
1216 [ # # ][ # # ]: 0 : pDocShell->PostPaintGridAll();
1217 : : }
1218 [ # # ]: 0 : else if (pSearchItem->GetCellType() == SVX_SEARCHIN_NOTE)
1219 : : {
1220 : 0 : ScPostIt* pNote = pDoc->GetNotes( aCursorPos.Tab() )->findByAddress( aCursorPos );
1221 : : OSL_ENSURE( pNote, "ScUndoReplace::Undo - cell does not contain a note" );
1222 [ # # ]: 0 : if (pNote)
1223 [ # # ]: 0 : pNote->SetText( aCursorPos, aUndoStr );
1224 [ # # ]: 0 : if (pViewShell)
1225 : 0 : pViewShell->MoveCursorAbs( aCursorPos.Col(), aCursorPos.Row(),
1226 : 0 : SC_FOLLOW_JUMP, false, false );
1227 : : }
1228 : : else
1229 : : {
1230 : : // aUndoStr may contain line breaks
1231 [ # # ]: 0 : if ( aUndoStr.Search('\n') != STRING_NOTFOUND )
1232 [ # # ][ # # ]: 0 : pDoc->PutCell( aCursorPos, new ScEditCell( aUndoStr, pDoc ) );
[ # # ]
1233 : : else
1234 [ # # ]: 0 : pDoc->SetString( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aUndoStr );
1235 [ # # ]: 0 : if (pViewShell)
1236 : 0 : pViewShell->MoveCursorAbs( aCursorPos.Col(), aCursorPos.Row(),
1237 : 0 : SC_FOLLOW_JUMP, false, false );
1238 : 0 : pDocShell->PostPaintGridAll();
1239 : : }
1240 : :
1241 : 0 : ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
1242 [ # # ]: 0 : if ( pChangeTrack )
1243 : 0 : pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
1244 : :
1245 : 0 : EndUndo();
1246 : 0 : }
1247 : :
1248 : :
1249 : : //----------------------------------------------------------------------------
1250 : :
1251 : 0 : void ScUndoReplace::Redo()
1252 : : {
1253 : 0 : BeginRedo();
1254 : :
1255 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1256 : 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1257 : :
1258 [ # # ]: 0 : if (pViewShell)
1259 : 0 : pViewShell->MoveCursorAbs( aCursorPos.Col(), aCursorPos.Row(),
1260 : 0 : SC_FOLLOW_JUMP, false, false );
1261 [ # # ]: 0 : if (pUndoDoc)
1262 : : {
1263 [ # # ]: 0 : if (pViewShell)
1264 : : {
1265 : 0 : SetViewMarkData( aMarkData );
1266 : :
1267 : 0 : pViewShell->SearchAndReplace( pSearchItem, false, sal_True );
1268 : : }
1269 : : }
1270 [ # # # # ]: 0 : else if (pSearchItem->GetPattern() &&
[ # # ]
1271 : 0 : pSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE)
1272 : : {
1273 : : pDoc->ReplaceStyle( *pSearchItem,
1274 : 0 : aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(),
1275 : 0 : aMarkData, sal_True);
1276 : 0 : pDocShell->PostPaintGridAll();
1277 : : }
1278 : : else
1279 [ # # ]: 0 : if (pViewShell)
1280 : 0 : pViewShell->SearchAndReplace( pSearchItem, false, sal_True );
1281 : :
1282 : 0 : SetChangeTrack();
1283 : :
1284 : 0 : EndRedo();
1285 : 0 : }
1286 : :
1287 : :
1288 : : //----------------------------------------------------------------------------
1289 : :
1290 : 0 : void ScUndoReplace::Repeat(SfxRepeatTarget& rTarget)
1291 : : {
1292 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
1293 : 0 : ((ScTabViewTarget&)rTarget).GetViewShell()->SearchAndReplace( pSearchItem, sal_True, false );
1294 : 0 : }
1295 : :
1296 : :
1297 : : //----------------------------------------------------------------------------
1298 : :
1299 : 4 : sal_Bool ScUndoReplace::CanRepeat(SfxRepeatTarget& rTarget) const
1300 : : {
1301 : 4 : return (rTarget.ISA(ScTabViewTarget));
1302 : : }
1303 : :
1304 : :
1305 : : //============================================================================
1306 : : // class ScUndoTabOp
1307 : : //
1308 : : // Mehrfachoperation (nur einfache Bloecke)
1309 : :
1310 : : //----------------------------------------------------------------------------
1311 : :
1312 : 6 : ScUndoTabOp::ScUndoTabOp( ScDocShell* pNewDocShell,
1313 : : SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
1314 : : SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, ScDocument* pNewUndoDoc,
1315 : : const ScRefAddress& rFormulaCell,
1316 : : const ScRefAddress& rFormulaEnd,
1317 : : const ScRefAddress& rRowCell,
1318 : : const ScRefAddress& rColCell,
1319 : : sal_uInt8 nMd )
1320 : : //
1321 : : : ScSimpleUndo( pNewDocShell ),
1322 : : //
1323 : : aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ),
1324 : : pUndoDoc ( pNewUndoDoc ),
1325 : : theFormulaCell ( rFormulaCell ),
1326 : : theFormulaEnd ( rFormulaEnd ),
1327 : : theRowCell ( rRowCell ),
1328 : : theColCell ( rColCell ),
1329 : 6 : nMode ( nMd )
1330 : : {
1331 : 6 : }
1332 : :
1333 : :
1334 : : //----------------------------------------------------------------------------
1335 : :
1336 : 6 : ScUndoTabOp::~ScUndoTabOp()
1337 : : {
1338 [ + - ][ + - ]: 6 : delete pUndoDoc;
1339 [ - + ]: 12 : }
1340 : :
1341 : :
1342 : : //----------------------------------------------------------------------------
1343 : :
1344 : 6 : rtl::OUString ScUndoTabOp::GetComment() const
1345 : : {
1346 : 6 : return ScGlobal::GetRscString( STR_UNDO_TABOP ); // "Mehrfachoperation"
1347 : : }
1348 : :
1349 : :
1350 : : //----------------------------------------------------------------------------
1351 : :
1352 : 0 : void ScUndoTabOp::Undo()
1353 : : {
1354 [ # # ]: 0 : BeginUndo();
1355 : :
1356 [ # # ]: 0 : ScUndoUtil::MarkSimpleBlock( pDocShell, aRange );
1357 : :
1358 : 0 : sal_uInt16 nExtFlags = 0;
1359 [ # # ]: 0 : pDocShell->UpdatePaintExt( nExtFlags, aRange );
1360 : :
1361 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1362 [ # # ]: 0 : pDoc->DeleteAreaTab( aRange,IDF_ALL & ~IDF_NOTE );
1363 [ # # ]: 0 : pUndoDoc->CopyToDocument( aRange, IDF_ALL & ~IDF_NOTE, false, pDoc );
1364 [ # # ][ # # ]: 0 : pDocShell->PostPaint( aRange, PAINT_GRID, nExtFlags );
[ # # ]
1365 [ # # ]: 0 : pDocShell->PostDataChanged();
1366 [ # # ]: 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1367 [ # # ]: 0 : if (pViewShell)
1368 [ # # ]: 0 : pViewShell->CellContentChanged();
1369 : :
1370 [ # # ]: 0 : EndUndo();
1371 : 0 : }
1372 : :
1373 : :
1374 : : //----------------------------------------------------------------------------
1375 : :
1376 : 0 : void ScUndoTabOp::Redo()
1377 : : {
1378 [ # # ]: 0 : BeginRedo();
1379 : :
1380 [ # # ]: 0 : ScUndoUtil::MarkSimpleBlock( pDocShell, aRange );
1381 : :
1382 : : ScTabOpParam aParam( theFormulaCell, theFormulaEnd,
1383 : : theRowCell, theColCell,
1384 [ # # ]: 0 : nMode );
1385 : :
1386 [ # # ]: 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1387 [ # # ]: 0 : if (pViewShell)
1388 [ # # ]: 0 : pViewShell->TabOp( aParam, false);
1389 : :
1390 [ # # ]: 0 : EndRedo();
1391 : 0 : }
1392 : :
1393 : :
1394 : : //----------------------------------------------------------------------------
1395 : :
1396 : 0 : void ScUndoTabOp::Repeat(SfxRepeatTarget& /* rTarget */)
1397 : : {
1398 : 0 : }
1399 : :
1400 : :
1401 : : //----------------------------------------------------------------------------
1402 : :
1403 : 0 : sal_Bool ScUndoTabOp::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1404 : : {
1405 : 0 : return false;
1406 : : }
1407 : :
1408 : :
1409 : : //============================================================================
1410 : : // class ScUndoConversion
1411 : : //
1412 : : // Spelling
1413 : :
1414 : : //----------------------------------------------------------------------------
1415 : :
1416 : 0 : ScUndoConversion::ScUndoConversion(
1417 : : ScDocShell* pNewDocShell, const ScMarkData& rMark,
1418 : : SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScDocument* pNewUndoDoc,
1419 : : SCCOL nNewX, SCROW nNewY, SCTAB nNewZ, ScDocument* pNewRedoDoc,
1420 : : const ScConversionParam& rConvParam ) :
1421 : : ScSimpleUndo( pNewDocShell ),
1422 : : aMarkData( rMark ),
1423 : : aCursorPos( nCurX, nCurY, nCurZ ),
1424 : : pUndoDoc( pNewUndoDoc ),
1425 : : aNewCursorPos( nNewX, nNewY, nNewZ ),
1426 : : pRedoDoc( pNewRedoDoc ),
1427 [ # # ][ # # ]: 0 : maConvParam( rConvParam )
1428 : : {
1429 [ # # ]: 0 : SetChangeTrack();
1430 : 0 : }
1431 : :
1432 : :
1433 : : //----------------------------------------------------------------------------
1434 : :
1435 [ # # ][ # # ]: 0 : ScUndoConversion::~ScUndoConversion()
1436 : : {
1437 [ # # ][ # # ]: 0 : delete pUndoDoc;
1438 [ # # ][ # # ]: 0 : delete pRedoDoc;
1439 [ # # ]: 0 : }
1440 : :
1441 : :
1442 : : //----------------------------------------------------------------------------
1443 : :
1444 : 0 : void ScUndoConversion::SetChangeTrack()
1445 : : {
1446 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1447 : 0 : ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
1448 [ # # ]: 0 : if ( pChangeTrack )
1449 : : {
1450 [ # # ]: 0 : if ( pUndoDoc )
1451 : : pChangeTrack->AppendContentsIfInRefDoc( pUndoDoc,
1452 : 0 : nStartChangeAction, nEndChangeAction );
1453 : : else
1454 : : {
1455 : : OSL_FAIL( "ScUndoConversion::SetChangeTrack: kein UndoDoc" );
1456 : 0 : nStartChangeAction = nEndChangeAction = 0;
1457 : : }
1458 : : }
1459 : : else
1460 : 0 : nStartChangeAction = nEndChangeAction = 0;
1461 : 0 : }
1462 : :
1463 : : //----------------------------------------------------------------------------
1464 : :
1465 : 0 : rtl::OUString ScUndoConversion::GetComment() const
1466 : : {
1467 : 0 : rtl::OUString aText;
1468 [ # # # # ]: 0 : switch( maConvParam.GetType() )
1469 : : {
1470 [ # # ][ # # ]: 0 : case SC_CONVERSION_SPELLCHECK: aText = ScGlobal::GetRscString( STR_UNDO_SPELLING ); break;
1471 [ # # ][ # # ]: 0 : case SC_CONVERSION_HANGULHANJA: aText = ScGlobal::GetRscString( STR_UNDO_HANGULHANJA ); break;
1472 [ # # ][ # # ]: 0 : case SC_CONVERSION_CHINESE_TRANSL: aText = ScGlobal::GetRscString( STR_UNDO_CHINESE_TRANSLATION ); break;
1473 : : default: OSL_FAIL( "ScUndoConversion::GetComment - unknown conversion type" );
1474 : : }
1475 : 0 : return aText;
1476 : : }
1477 : :
1478 : :
1479 : : //----------------------------------------------------------------------------
1480 : :
1481 : 0 : void ScUndoConversion::DoChange( ScDocument* pRefDoc, const ScAddress& rCursorPos )
1482 : : {
1483 [ # # ]: 0 : if (pRefDoc)
1484 : : {
1485 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1486 : 0 : ShowTable( rCursorPos.Tab() );
1487 : :
1488 : 0 : SetViewMarkData( aMarkData );
1489 : :
1490 : 0 : SCTAB nTabCount = pDoc->GetTableCount();
1491 : : // Undo/Redo-doc has only selected tables
1492 : :
1493 : 0 : sal_Bool bMulti = aMarkData.IsMultiMarked();
1494 : : pRefDoc->CopyToDocument( 0, 0, 0,
1495 : : MAXCOL, MAXROW, nTabCount-1,
1496 : 0 : IDF_CONTENTS, bMulti, pDoc, &aMarkData );
1497 : 0 : pDocShell->PostPaintGridAll();
1498 : : }
1499 : : else
1500 : : {
1501 : : OSL_FAIL("Kein Un-/RedoDoc bei Un-/RedoSpelling");
1502 : : }
1503 : 0 : }
1504 : :
1505 : :
1506 : : //----------------------------------------------------------------------------
1507 : :
1508 : 0 : void ScUndoConversion::Undo()
1509 : : {
1510 : 0 : BeginUndo();
1511 : 0 : DoChange( pUndoDoc, aCursorPos );
1512 : 0 : ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
1513 [ # # ]: 0 : if ( pChangeTrack )
1514 : 0 : pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
1515 : 0 : EndUndo();
1516 : 0 : }
1517 : :
1518 : :
1519 : : //----------------------------------------------------------------------------
1520 : :
1521 : 0 : void ScUndoConversion::Redo()
1522 : : {
1523 : 0 : BeginRedo();
1524 : 0 : DoChange( pRedoDoc, aNewCursorPos );
1525 : 0 : SetChangeTrack();
1526 : 0 : EndRedo();
1527 : 0 : }
1528 : :
1529 : :
1530 : : //----------------------------------------------------------------------------
1531 : :
1532 : 0 : void ScUndoConversion::Repeat( SfxRepeatTarget& rTarget )
1533 : : {
1534 [ # # ]: 0 : if( rTarget.ISA( ScTabViewTarget ) )
1535 : 0 : ((ScTabViewTarget&)rTarget).GetViewShell()->DoSheetConversion( maConvParam, sal_True );
1536 : 0 : }
1537 : :
1538 : :
1539 : : //----------------------------------------------------------------------------
1540 : :
1541 : 0 : sal_Bool ScUndoConversion::CanRepeat(SfxRepeatTarget& rTarget) const
1542 : : {
1543 : 0 : return rTarget.ISA( ScTabViewTarget );
1544 : : }
1545 : :
1546 : :
1547 : : //============================================================================
1548 : : // class ScUndoRefConversion
1549 : : //
1550 : : // cell reference conversion
1551 : :
1552 : : //----------------------------------------------------------------------------
1553 : :
1554 : 0 : ScUndoRefConversion::ScUndoRefConversion( ScDocShell* pNewDocShell,
1555 : : const ScRange& aMarkRange, const ScMarkData& rMark,
1556 : : ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, sal_Bool bNewMulti, sal_uInt16 nNewFlag) :
1557 : : ScSimpleUndo( pNewDocShell ),
1558 : : aMarkData ( rMark ),
1559 : : pUndoDoc ( pNewUndoDoc ),
1560 : : pRedoDoc ( pNewRedoDoc ),
1561 : : aRange ( aMarkRange ),
1562 : : bMulti ( bNewMulti ),
1563 [ # # ]: 0 : nFlags ( nNewFlag )
1564 : : {
1565 [ # # ]: 0 : SetChangeTrack();
1566 : 0 : }
1567 : :
1568 [ # # ]: 0 : ScUndoRefConversion::~ScUndoRefConversion()
1569 : : {
1570 [ # # ][ # # ]: 0 : delete pUndoDoc;
1571 [ # # ][ # # ]: 0 : delete pRedoDoc;
1572 [ # # ]: 0 : }
1573 : :
1574 : 0 : rtl::OUString ScUndoRefConversion::GetComment() const
1575 : : {
1576 : 0 : return ScGlobal::GetRscString( STR_UNDO_ENTERDATA ); // "Eingabe"
1577 : : }
1578 : :
1579 : 0 : void ScUndoRefConversion::SetChangeTrack()
1580 : : {
1581 : 0 : ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
1582 [ # # ][ # # ]: 0 : if ( pChangeTrack && (nFlags & IDF_FORMULA) )
1583 : : pChangeTrack->AppendContentsIfInRefDoc( pUndoDoc,
1584 : 0 : nStartChangeAction, nEndChangeAction );
1585 : : else
1586 : 0 : nStartChangeAction = nEndChangeAction = 0;
1587 : 0 : }
1588 : :
1589 : 0 : void ScUndoRefConversion::DoChange( ScDocument* pRefDoc)
1590 : : {
1591 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1592 : :
1593 [ # # ]: 0 : ShowTable(aRange);
1594 : :
1595 [ # # ]: 0 : SetViewMarkData( aMarkData );
1596 : :
1597 : 0 : ScRange aCopyRange = aRange;
1598 [ # # ]: 0 : SCTAB nTabCount = pDoc->GetTableCount();
1599 : 0 : aCopyRange.aStart.SetTab(0);
1600 : 0 : aCopyRange.aEnd.SetTab(nTabCount-1);
1601 [ # # ]: 0 : pRefDoc->CopyToDocument( aCopyRange, nFlags, bMulti, pDoc, &aMarkData );
1602 [ # # ][ # # ]: 0 : pDocShell->PostPaint( aRange, PAINT_GRID);
[ # # ]
1603 [ # # ]: 0 : pDocShell->PostDataChanged();
1604 [ # # ]: 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1605 [ # # ]: 0 : if (pViewShell)
1606 [ # # ]: 0 : pViewShell->CellContentChanged();
1607 : 0 : }
1608 : 0 : void ScUndoRefConversion::Undo()
1609 : : {
1610 : 0 : BeginUndo();
1611 [ # # ]: 0 : if (pUndoDoc)
1612 : 0 : DoChange(pUndoDoc);
1613 : 0 : ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
1614 [ # # ]: 0 : if ( pChangeTrack )
1615 : 0 : pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
1616 : 0 : EndUndo();
1617 : 0 : }
1618 : :
1619 : 0 : void ScUndoRefConversion::Redo()
1620 : : {
1621 : 0 : BeginRedo();
1622 [ # # ]: 0 : if (pRedoDoc)
1623 : 0 : DoChange(pRedoDoc);
1624 : 0 : SetChangeTrack();
1625 : 0 : EndRedo();
1626 : 0 : }
1627 : :
1628 : 0 : void ScUndoRefConversion::Repeat(SfxRepeatTarget& rTarget)
1629 : : {
1630 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
1631 : 0 : ((ScTabViewTarget&)rTarget).GetViewShell()->DoRefConversion();
1632 : 0 : }
1633 : :
1634 : 0 : sal_Bool ScUndoRefConversion::CanRepeat(SfxRepeatTarget& rTarget) const
1635 : : {
1636 : 0 : return (rTarget.ISA(ScTabViewTarget));
1637 : : }
1638 : : //============================================================================
1639 : : // class ScUndoRefreshLink
1640 : : //
1641 : : // Link aktualisieren / aendern
1642 : :
1643 : : //----------------------------------------------------------------------------
1644 : :
1645 : 2 : ScUndoRefreshLink::ScUndoRefreshLink( ScDocShell* pNewDocShell,
1646 : : ScDocument* pNewUndoDoc )
1647 : : //
1648 : : : ScSimpleUndo( pNewDocShell ),
1649 : : //
1650 : : pUndoDoc( pNewUndoDoc ),
1651 : 2 : pRedoDoc( NULL )
1652 : : {
1653 : 2 : }
1654 : :
1655 : :
1656 : : //----------------------------------------------------------------------------
1657 : :
1658 : 2 : ScUndoRefreshLink::~ScUndoRefreshLink()
1659 : : {
1660 [ + - ][ + - ]: 2 : delete pUndoDoc;
1661 [ - + ][ # # ]: 2 : delete pRedoDoc;
1662 [ - + ]: 4 : }
1663 : :
1664 : :
1665 : : //----------------------------------------------------------------------------
1666 : :
1667 : 6 : rtl::OUString ScUndoRefreshLink::GetComment() const
1668 : : {
1669 : 6 : return ScGlobal::GetRscString( STR_UNDO_UPDATELINK );
1670 : : }
1671 : :
1672 : :
1673 : : //----------------------------------------------------------------------------
1674 : :
1675 : 0 : void ScUndoRefreshLink::Undo()
1676 : : {
1677 : 0 : BeginUndo();
1678 : :
1679 : 0 : sal_Bool bMakeRedo = !pRedoDoc;
1680 [ # # ]: 0 : if (bMakeRedo)
1681 [ # # ]: 0 : pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
1682 : :
1683 : 0 : sal_Bool bFirst = sal_True;
1684 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1685 : 0 : SCTAB nCount = pDoc->GetTableCount();
1686 [ # # ]: 0 : for (SCTAB nTab=0; nTab<nCount; nTab++)
1687 [ # # ]: 0 : if (pUndoDoc->HasTable(nTab))
1688 : : {
1689 : 0 : ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab);
1690 [ # # ]: 0 : if (bMakeRedo)
1691 : : {
1692 [ # # ]: 0 : if (bFirst)
1693 [ # # ]: 0 : pRedoDoc->InitUndo( pDoc, nTab, nTab, sal_True, sal_True );
1694 : : else
1695 [ # # ]: 0 : pRedoDoc->AddUndoTab( nTab, nTab, true, true );
1696 : 0 : bFirst = false;
1697 [ # # ]: 0 : pDoc->CopyToDocument(aRange, IDF_ALL, false, pRedoDoc);
1698 : : pRedoDoc->SetLink( nTab,
1699 [ # # ]: 0 : pDoc->GetLinkMode(nTab),
1700 : : pDoc->GetLinkDoc(nTab),
1701 : : pDoc->GetLinkFlt(nTab),
1702 : : pDoc->GetLinkOpt(nTab),
1703 : : pDoc->GetLinkTab(nTab),
1704 [ # # ][ # # ]: 0 : pDoc->GetLinkRefreshDelay(nTab) );
[ # # ][ # # ]
[ # # ][ # # ]
1705 : : }
1706 : :
1707 [ # # ]: 0 : pDoc->DeleteAreaTab( aRange,IDF_ALL );
1708 [ # # ]: 0 : pUndoDoc->CopyToDocument( aRange, IDF_ALL, false, pDoc );
1709 [ # # ]: 0 : pDoc->SetLink( nTab, pUndoDoc->GetLinkMode(nTab), pUndoDoc->GetLinkDoc(nTab),
1710 : : pUndoDoc->GetLinkFlt(nTab), pUndoDoc->GetLinkOpt(nTab),
1711 : : pUndoDoc->GetLinkTab(nTab),
1712 [ # # ][ # # ]: 0 : pUndoDoc->GetLinkRefreshDelay(nTab) );
[ # # ][ # # ]
[ # # ][ # # ]
1713 : : }
1714 : :
1715 : 0 : pDocShell->PostPaintGridAll();
1716 : :
1717 : 0 : EndUndo();
1718 : 0 : }
1719 : :
1720 : :
1721 : : //----------------------------------------------------------------------------
1722 : :
1723 : 0 : void ScUndoRefreshLink::Redo()
1724 : : {
1725 : : OSL_ENSURE(pRedoDoc, "Kein RedoDoc bei ScUndoRefreshLink::Redo");
1726 : :
1727 : 0 : BeginUndo();
1728 : :
1729 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1730 : 0 : SCTAB nCount = pDoc->GetTableCount();
1731 [ # # ]: 0 : for (SCTAB nTab=0; nTab<nCount; nTab++)
1732 [ # # ]: 0 : if (pRedoDoc->HasTable(nTab))
1733 : : {
1734 : 0 : ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab);
1735 : :
1736 [ # # ]: 0 : pDoc->DeleteAreaTab( aRange, IDF_ALL );
1737 [ # # ]: 0 : pRedoDoc->CopyToDocument( aRange, IDF_ALL, false, pDoc );
1738 : : pDoc->SetLink( nTab,
1739 [ # # ]: 0 : pRedoDoc->GetLinkMode(nTab),
1740 : : pRedoDoc->GetLinkDoc(nTab),
1741 : : pRedoDoc->GetLinkFlt(nTab),
1742 : : pRedoDoc->GetLinkOpt(nTab),
1743 : : pRedoDoc->GetLinkTab(nTab),
1744 [ # # ][ # # ]: 0 : pRedoDoc->GetLinkRefreshDelay(nTab) );
[ # # ][ # # ]
[ # # ][ # # ]
1745 : : }
1746 : :
1747 : 0 : pDocShell->PostPaintGridAll();
1748 : :
1749 : 0 : EndUndo();
1750 : 0 : }
1751 : :
1752 : :
1753 : : //----------------------------------------------------------------------------
1754 : :
1755 : 0 : void ScUndoRefreshLink::Repeat(SfxRepeatTarget& /* rTarget */)
1756 : : {
1757 : : // gippsnich
1758 : 0 : }
1759 : :
1760 : :
1761 : : //----------------------------------------------------------------------------
1762 : :
1763 : 4 : sal_Bool ScUndoRefreshLink::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1764 : : {
1765 : 4 : return false;
1766 : : }
1767 : :
1768 : :
1769 : : //----------------------------------------------------------------------------
1770 : :
1771 : 0 : ScAreaLink* lcl_FindAreaLink( sfx2::LinkManager* pLinkManager, const String& rDoc,
1772 : : const String& rFlt, const String& rOpt,
1773 : : const String& rSrc, const ScRange& rDest )
1774 : : {
1775 : 0 : const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
1776 : 0 : sal_uInt16 nCount = pLinkManager->GetLinks().size();
1777 [ # # ]: 0 : for (sal_uInt16 i=0; i<nCount; i++)
1778 : : {
1779 : 0 : ::sfx2::SvBaseLink* pBase = *rLinks[i];
1780 [ # # ]: 0 : if (pBase->ISA(ScAreaLink))
1781 [ # # ]: 0 : if ( ((ScAreaLink*)pBase)->IsEqual( rDoc, rFlt, rOpt, rSrc, rDest ) )
1782 : 0 : return (ScAreaLink*)pBase;
1783 : : }
1784 : :
1785 : : OSL_FAIL("ScAreaLink nicht gefunden");
1786 : 0 : return NULL;
1787 : : }
1788 : :
1789 : :
1790 : : //============================================================================
1791 : : // class ScUndoInsertAreaLink
1792 : : //
1793 : : // Bereichs-Verknuepfung einfuegen
1794 : :
1795 : : //----------------------------------------------------------------------------
1796 : :
1797 : 16 : ScUndoInsertAreaLink::ScUndoInsertAreaLink( ScDocShell* pShell,
1798 : : const String& rDoc,
1799 : : const String& rFlt, const String& rOpt,
1800 : : const String& rArea, const ScRange& rDestRange,
1801 : : sal_uLong nRefresh )
1802 : : //
1803 : : : ScSimpleUndo ( pShell ),
1804 : : //
1805 : : aDocName ( rDoc ),
1806 : : aFltName ( rFlt ),
1807 : : aOptions ( rOpt ),
1808 : : aAreaName ( rArea ),
1809 : : aRange ( rDestRange ),
1810 [ + - ][ + - ]: 16 : nRefreshDelay ( nRefresh )
[ + - ][ + - ]
1811 : : {
1812 : 16 : }
1813 : :
1814 : :
1815 : : //----------------------------------------------------------------------------
1816 : :
1817 [ + - ][ + - ]: 16 : ScUndoInsertAreaLink::~ScUndoInsertAreaLink()
[ + - ][ + - ]
1818 : : {
1819 [ - + ]: 32 : }
1820 : :
1821 : :
1822 : : //----------------------------------------------------------------------------
1823 : :
1824 : 16 : rtl::OUString ScUndoInsertAreaLink::GetComment() const
1825 : : {
1826 : 16 : return ScGlobal::GetRscString( STR_UNDO_INSERTAREALINK );
1827 : : }
1828 : :
1829 : :
1830 : : //----------------------------------------------------------------------------
1831 : :
1832 : 0 : void ScUndoInsertAreaLink::Undo()
1833 : : {
1834 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1835 : 0 : sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
1836 : :
1837 : : ScAreaLink* pLink = lcl_FindAreaLink( pLinkManager, aDocName, aFltName, aOptions,
1838 : 0 : aAreaName, aRange );
1839 [ # # ]: 0 : if (pLink)
1840 : 0 : pLinkManager->Remove( pLink );
1841 : :
1842 [ # # ][ # # ]: 0 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator
1843 : 0 : }
1844 : :
1845 : :
1846 : : //----------------------------------------------------------------------------
1847 : :
1848 : 0 : void ScUndoInsertAreaLink::Redo()
1849 : : {
1850 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1851 : 0 : sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
1852 : :
1853 : : ScAreaLink* pLink = new ScAreaLink( pDocShell, aDocName, aFltName, aOptions,
1854 [ # # ][ # # ]: 0 : aAreaName, aRange.aStart, nRefreshDelay );
1855 : 0 : pLink->SetInCreate( sal_True );
1856 : 0 : pLink->SetDestArea( aRange );
1857 : 0 : pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aDocName, &aFltName, &aAreaName );
1858 : 0 : pLink->Update();
1859 : 0 : pLink->SetInCreate( false );
1860 : :
1861 [ # # ][ # # ]: 0 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator
1862 : 0 : }
1863 : :
1864 : :
1865 : : //----------------------------------------------------------------------------
1866 : :
1867 : 0 : void ScUndoInsertAreaLink::Repeat(SfxRepeatTarget& /* rTarget */)
1868 : : {
1869 : : //! ....
1870 : 0 : }
1871 : :
1872 : :
1873 : : //----------------------------------------------------------------------------
1874 : :
1875 : 0 : sal_Bool ScUndoInsertAreaLink::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1876 : : {
1877 : 0 : return false;
1878 : : }
1879 : :
1880 : :
1881 : : //============================================================================
1882 : : // class ScUndoRemoveAreaLink
1883 : : //
1884 : : // Bereichs-Verknuepfung loeschen
1885 : :
1886 : : //----------------------------------------------------------------------------
1887 : :
1888 : 0 : ScUndoRemoveAreaLink::ScUndoRemoveAreaLink( ScDocShell* pShell,
1889 : : const String& rDoc, const String& rFlt, const String& rOpt,
1890 : : const String& rArea, const ScRange& rDestRange,
1891 : : sal_uLong nRefresh )
1892 : : //
1893 : : : ScSimpleUndo ( pShell ),
1894 : : //
1895 : : aDocName ( rDoc ),
1896 : : aFltName ( rFlt ),
1897 : : aOptions ( rOpt ),
1898 : : aAreaName ( rArea ),
1899 : : aRange ( rDestRange ),
1900 [ # # ][ # # ]: 0 : nRefreshDelay ( nRefresh )
[ # # ][ # # ]
1901 : : {
1902 : 0 : }
1903 : :
1904 : :
1905 : : //----------------------------------------------------------------------------
1906 : :
1907 [ # # ][ # # ]: 0 : ScUndoRemoveAreaLink::~ScUndoRemoveAreaLink()
[ # # ][ # # ]
1908 : : {
1909 [ # # ]: 0 : }
1910 : :
1911 : :
1912 : : //----------------------------------------------------------------------------
1913 : :
1914 : 0 : rtl::OUString ScUndoRemoveAreaLink::GetComment() const
1915 : : {
1916 : 0 : return ScGlobal::GetRscString( STR_UNDO_REMOVELINK ); //! eigener Text ??
1917 : : }
1918 : :
1919 : :
1920 : : //----------------------------------------------------------------------------
1921 : :
1922 : 0 : void ScUndoRemoveAreaLink::Undo()
1923 : : {
1924 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1925 : 0 : sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
1926 : :
1927 : : ScAreaLink* pLink = new ScAreaLink( pDocShell, aDocName, aFltName, aOptions,
1928 [ # # ][ # # ]: 0 : aAreaName, aRange.aStart, nRefreshDelay );
1929 : 0 : pLink->SetInCreate( sal_True );
1930 : 0 : pLink->SetDestArea( aRange );
1931 : 0 : pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aDocName, &aFltName, &aAreaName );
1932 : 0 : pLink->Update();
1933 : 0 : pLink->SetInCreate( false );
1934 : :
1935 [ # # ][ # # ]: 0 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator
1936 : 0 : }
1937 : :
1938 : :
1939 : : //----------------------------------------------------------------------------
1940 : :
1941 : 0 : void ScUndoRemoveAreaLink::Redo()
1942 : : {
1943 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1944 : 0 : sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
1945 : :
1946 : : ScAreaLink* pLink = lcl_FindAreaLink( pLinkManager, aDocName, aFltName, aOptions,
1947 : 0 : aAreaName, aRange );
1948 [ # # ]: 0 : if (pLink)
1949 : 0 : pLinkManager->Remove( pLink );
1950 : :
1951 [ # # ][ # # ]: 0 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator
1952 : 0 : }
1953 : :
1954 : :
1955 : : //----------------------------------------------------------------------------
1956 : :
1957 : 0 : void ScUndoRemoveAreaLink::Repeat(SfxRepeatTarget& /* rTarget */)
1958 : : {
1959 : : // gippsnich
1960 : 0 : }
1961 : :
1962 : :
1963 : : //----------------------------------------------------------------------------
1964 : :
1965 : 0 : sal_Bool ScUndoRemoveAreaLink::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1966 : : {
1967 : 0 : return false;
1968 : : }
1969 : :
1970 : :
1971 : : //============================================================================
1972 : : // class ScUndoUpdateAreaLink
1973 : : //
1974 : : // Bereichs-Verknuepfung aktualisieren
1975 : :
1976 : : //----------------------------------------------------------------------------
1977 : :
1978 : 4 : ScUndoUpdateAreaLink::ScUndoUpdateAreaLink( ScDocShell* pShell,
1979 : : const String& rOldD, const String& rOldF, const String& rOldO,
1980 : : const String& rOldA, const ScRange& rOldR, sal_uLong nOldRD,
1981 : : const String& rNewD, const String& rNewF, const String& rNewO,
1982 : : const String& rNewA, const ScRange& rNewR, sal_uLong nNewRD,
1983 : : ScDocument* pUndo, ScDocument* pRedo, sal_Bool bDoInsert )
1984 : : //
1985 : : : ScSimpleUndo( pShell ),
1986 : : //
1987 : : aOldDoc ( rOldD ),
1988 : : aOldFlt ( rOldF ),
1989 : : aOldOpt ( rOldO ),
1990 : : aOldArea ( rOldA ),
1991 : : aOldRange ( rOldR ),
1992 : : aNewDoc ( rNewD ),
1993 : : aNewFlt ( rNewF ),
1994 : : aNewOpt ( rNewO ),
1995 : : aNewArea ( rNewA ),
1996 : : aNewRange ( rNewR ),
1997 : : pUndoDoc ( pUndo ),
1998 : : pRedoDoc ( pRedo ),
1999 : : nOldRefresh ( nOldRD ),
2000 : : nNewRefresh ( nNewRD ),
2001 [ + - ][ + - ]: 4 : bWithInsert ( bDoInsert )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
2002 : : {
2003 : : OSL_ENSURE( aOldRange.aStart == aNewRange.aStart, "AreaLink verschoben ?" );
2004 : 4 : }
2005 : :
2006 : :
2007 : : //----------------------------------------------------------------------------
2008 : :
2009 [ + - ][ + - ]: 4 : ScUndoUpdateAreaLink::~ScUndoUpdateAreaLink()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
2010 : : {
2011 [ + - ][ + - ]: 4 : delete pUndoDoc;
2012 [ + - ][ + - ]: 4 : delete pRedoDoc;
2013 [ - + ]: 8 : }
2014 : :
2015 : :
2016 : : //----------------------------------------------------------------------------
2017 : :
2018 : 10 : rtl::OUString ScUndoUpdateAreaLink::GetComment() const
2019 : : {
2020 : 10 : return ScGlobal::GetRscString( STR_UNDO_UPDATELINK ); //! eigener Text ??
2021 : : }
2022 : :
2023 : :
2024 : : //----------------------------------------------------------------------------
2025 : :
2026 : 0 : void ScUndoUpdateAreaLink::DoChange( const sal_Bool bUndo ) const
2027 : : {
2028 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
2029 : :
2030 : 0 : SCCOL nEndX = Max( aOldRange.aEnd.Col(), aNewRange.aEnd.Col() );
2031 : 0 : SCROW nEndY = Max( aOldRange.aEnd.Row(), aNewRange.aEnd.Row() );
2032 : 0 : SCTAB nEndZ = Max( aOldRange.aEnd.Tab(), aNewRange.aEnd.Tab() ); //?
2033 : :
2034 [ # # ]: 0 : if ( bUndo )
2035 : : {
2036 [ # # ]: 0 : if ( bWithInsert )
2037 : : {
2038 [ # # ]: 0 : pDoc->FitBlock( aNewRange, aOldRange );
2039 [ # # ]: 0 : pDoc->DeleteAreaTab( aOldRange, IDF_ALL & ~IDF_NOTE );
2040 [ # # ]: 0 : pUndoDoc->UndoToDocument( aOldRange, IDF_ALL & ~IDF_NOTE, false, pDoc );
2041 : : }
2042 : : else
2043 : : {
2044 : 0 : ScRange aCopyRange( aOldRange.aStart, ScAddress(nEndX,nEndY,nEndZ) );
2045 [ # # ]: 0 : pDoc->DeleteAreaTab( aCopyRange, IDF_ALL & ~IDF_NOTE );
2046 [ # # ]: 0 : pUndoDoc->CopyToDocument( aCopyRange, IDF_ALL & ~IDF_NOTE, false, pDoc );
2047 : : }
2048 : : }
2049 : : else
2050 : : {
2051 [ # # ]: 0 : if ( bWithInsert )
2052 : : {
2053 [ # # ]: 0 : pDoc->FitBlock( aOldRange, aNewRange );
2054 [ # # ]: 0 : pDoc->DeleteAreaTab( aNewRange, IDF_ALL & ~IDF_NOTE );
2055 [ # # ]: 0 : pRedoDoc->CopyToDocument( aNewRange, IDF_ALL & ~IDF_NOTE, false, pDoc );
2056 : : }
2057 : : else
2058 : : {
2059 : 0 : ScRange aCopyRange( aOldRange.aStart, ScAddress(nEndX,nEndY,nEndZ) );
2060 [ # # ]: 0 : pDoc->DeleteAreaTab( aCopyRange, IDF_ALL & ~IDF_NOTE );
2061 [ # # ]: 0 : pRedoDoc->CopyToDocument( aCopyRange, IDF_ALL & ~IDF_NOTE, false, pDoc );
2062 : : }
2063 : : }
2064 : :
2065 : 0 : ScRange aWorkRange( aNewRange.aStart, ScAddress( nEndX, nEndY, nEndZ ) );
2066 [ # # ]: 0 : pDoc->ExtendMerge( aWorkRange, sal_True );
2067 : :
2068 : : // Paint
2069 : :
2070 [ # # ]: 0 : if ( aNewRange.aEnd.Col() != aOldRange.aEnd.Col() )
2071 : 0 : aWorkRange.aEnd.SetCol(MAXCOL);
2072 [ # # ]: 0 : if ( aNewRange.aEnd.Row() != aOldRange.aEnd.Row() )
2073 : 0 : aWorkRange.aEnd.SetRow(MAXROW);
2074 : :
2075 [ # # ][ # # ]: 0 : if ( !pDocShell->AdjustRowHeight( aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), aWorkRange.aStart.Tab() ) )
2076 [ # # ][ # # ]: 0 : pDocShell->PostPaint( aWorkRange, PAINT_GRID );
[ # # ]
2077 : :
2078 [ # # ]: 0 : pDocShell->PostDataChanged();
2079 [ # # ]: 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
2080 [ # # ]: 0 : if (pViewShell)
2081 [ # # ]: 0 : pViewShell->CellContentChanged();
2082 : 0 : }
2083 : :
2084 : :
2085 : : //----------------------------------------------------------------------------
2086 : :
2087 : 0 : void ScUndoUpdateAreaLink::Undo()
2088 : : {
2089 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
2090 : 0 : sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
2091 : : ScAreaLink* pLink = lcl_FindAreaLink( pLinkManager, aNewDoc, aNewFlt, aNewOpt,
2092 : 0 : aNewArea, aNewRange );
2093 [ # # ]: 0 : if (pLink)
2094 : : {
2095 : 0 : pLink->SetSource( aOldDoc, aOldFlt, aOldOpt, aOldArea ); // alte Werte im Link
2096 : 0 : pLink->SetDestArea( aOldRange );
2097 : 0 : pLink->SetRefreshDelay( nOldRefresh );
2098 : : }
2099 : :
2100 : 0 : DoChange(sal_True);
2101 : 0 : }
2102 : :
2103 : :
2104 : : //----------------------------------------------------------------------------
2105 : :
2106 : 0 : void ScUndoUpdateAreaLink::Redo()
2107 : : {
2108 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
2109 : 0 : sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
2110 : : ScAreaLink* pLink = lcl_FindAreaLink( pLinkManager, aOldDoc, aOldFlt, aOldOpt,
2111 : 0 : aOldArea, aOldRange );
2112 [ # # ]: 0 : if (pLink)
2113 : : {
2114 : 0 : pLink->SetSource( aNewDoc, aNewFlt, aNewOpt, aNewArea ); // neue Werte im Link
2115 : 0 : pLink->SetDestArea( aNewRange );
2116 : 0 : pLink->SetRefreshDelay( nNewRefresh );
2117 : : }
2118 : :
2119 : 0 : DoChange(false);
2120 : 0 : }
2121 : :
2122 : :
2123 : : //----------------------------------------------------------------------------
2124 : :
2125 : 0 : void ScUndoUpdateAreaLink::Repeat(SfxRepeatTarget& /* rTarget */)
2126 : : {
2127 : : // gippsnich
2128 : 0 : }
2129 : :
2130 : :
2131 : : //----------------------------------------------------------------------------
2132 : :
2133 : 6 : sal_Bool ScUndoUpdateAreaLink::CanRepeat(SfxRepeatTarget& /* rTarget */) const
2134 : : {
2135 : 6 : return false;
2136 : : }
2137 : :
2138 : :
2139 : :
2140 : :
2141 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|