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 "scitems.hxx"
31 : : #include <editeng/eeitem.hxx>
32 : :
33 : : #include <editeng/editobj.hxx>
34 : : #include <svl/zforlist.hxx>
35 : : #include <sfx2/app.hxx>
36 : :
37 : : #include "undocell.hxx"
38 : : #include "document.hxx"
39 : : #include "docpool.hxx"
40 : : #include "patattr.hxx"
41 : : #include "docsh.hxx"
42 : : #include "tabvwsh.hxx"
43 : : #include "globstr.hrc"
44 : : #include "global.hxx"
45 : : #include "cell.hxx"
46 : : #include "target.hxx"
47 : : #include "undoolk.hxx"
48 : : #include "detdata.hxx"
49 : : #include "stlpool.hxx"
50 : : #include "printfun.hxx"
51 : : #include "rangenam.hxx"
52 : : #include "chgtrack.hxx"
53 : : #include "sc.hrc"
54 : : #include "docuno.hxx"
55 : :
56 : : using ::boost::shared_ptr;
57 : :
58 : : // STATIC DATA -----------------------------------------------------------
59 : :
60 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoCursorAttr, ScSimpleUndo);
61 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoEnterData, ScSimpleUndo);
62 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoEnterValue, ScSimpleUndo);
63 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoPutCell, ScSimpleUndo);
64 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoPageBreak, ScSimpleUndo);
65 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoPrintZoom, ScSimpleUndo);
66 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoThesaurus, ScSimpleUndo);
67 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoReplaceNote, ScSimpleUndo);
68 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoShowHideNote, ScSimpleUndo);
69 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoDetective, ScSimpleUndo);
70 [ # # ][ # # ]: 0 : TYPEINIT1(ScUndoRangeNames, ScSimpleUndo);
71 : :
72 : :
73 : : // -----------------------------------------------------------------------
74 : : //
75 : : // Attribute auf Cursor anwenden
76 : : //
77 : :
78 : 0 : ScUndoCursorAttr::ScUndoCursorAttr( ScDocShell* pNewDocShell,
79 : : SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
80 : : const ScPatternAttr* pOldPat, const ScPatternAttr* pNewPat,
81 : : const ScPatternAttr* pApplyPat, sal_Bool bAutomatic ) :
82 : : ScSimpleUndo( pNewDocShell ),
83 : : nCol( nNewCol ),
84 : : nRow( nNewRow ),
85 : : nTab( nNewTab ),
86 : : pOldEditData( static_cast<EditTextObject*>(NULL) ),
87 : : pNewEditData( static_cast<EditTextObject*>(NULL) ),
88 [ # # ][ # # ]: 0 : bIsAutomatic( bAutomatic )
89 : : {
90 [ # # ]: 0 : ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
91 [ # # ]: 0 : pNewPattern = (ScPatternAttr*) &pPool->Put( *pNewPat );
92 [ # # ]: 0 : pOldPattern = (ScPatternAttr*) &pPool->Put( *pOldPat );
93 [ # # ]: 0 : pApplyPattern = (ScPatternAttr*) &pPool->Put( *pApplyPat );
94 : 0 : }
95 : :
96 [ # # ][ # # ]: 0 : ScUndoCursorAttr::~ScUndoCursorAttr()
97 : : {
98 [ # # ]: 0 : ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
99 [ # # ]: 0 : pPool->Remove(*pNewPattern);
100 [ # # ]: 0 : pPool->Remove(*pOldPattern);
101 [ # # ]: 0 : pPool->Remove(*pApplyPattern);
102 [ # # ]: 0 : }
103 : :
104 : 0 : rtl::OUString ScUndoCursorAttr::GetComment() const
105 : : {
106 : : //! eigener Text fuer automatische Attributierung
107 : :
108 : 0 : sal_uInt16 nId = STR_UNDO_CURSORATTR; // "Attribute"
109 : 0 : return ScGlobal::GetRscString( nId );
110 : : }
111 : :
112 : 0 : void ScUndoCursorAttr::SetEditData( EditTextObject* pOld, EditTextObject* pNew )
113 : : {
114 : 0 : pOldEditData.reset(pOld);
115 : 0 : pNewEditData.reset(pNew);
116 : 0 : }
117 : :
118 : 0 : void ScUndoCursorAttr::DoChange( const ScPatternAttr* pWhichPattern, const shared_ptr<EditTextObject>& pEditData ) const
119 : : {
120 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
121 [ # # ]: 0 : pDoc->SetPattern( nCol, nRow, nTab, *pWhichPattern, true );
122 : :
123 : : ScBaseCell* pCell;
124 [ # # ]: 0 : pDoc->GetCell(nCol, nRow, nTab, pCell);
125 [ # # ][ # # ]: 0 : if (pCell && pCell->GetCellType() == CELLTYPE_EDIT && pEditData.get())
[ # # ][ # # ]
126 [ # # ]: 0 : static_cast<ScEditCell*>(pCell)->SetData(pEditData.get(), NULL);
127 : :
128 [ # # ]: 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
129 [ # # ]: 0 : if (pViewShell)
130 : : {
131 [ # # ]: 0 : pViewShell->SetTabNo( nTab );
132 [ # # ]: 0 : pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, false, false );
133 [ # # ]: 0 : pViewShell->AdjustBlockHeight();
134 : : }
135 : :
136 : 0 : const SfxItemSet& rApplySet = pApplyPattern->GetItemSet();
137 [ # # ]: 0 : sal_Bool bPaintExt = ( rApplySet.GetItemState( ATTR_SHADOW, sal_True ) != SFX_ITEM_DEFAULT ||
138 [ # # ][ # # ]: 0 : rApplySet.GetItemState( ATTR_CONDITIONAL, sal_True ) != SFX_ITEM_DEFAULT );
[ # # ]
139 [ # # ]: 0 : sal_Bool bPaintRows = ( rApplySet.GetItemState( ATTR_HOR_JUSTIFY, sal_True ) != SFX_ITEM_DEFAULT );
140 : :
141 : 0 : sal_uInt16 nFlags = SC_PF_TESTMERGE;
142 [ # # ]: 0 : if (bPaintExt)
143 : 0 : nFlags |= SC_PF_LINES;
144 [ # # ]: 0 : if (bPaintRows)
145 : 0 : nFlags |= SC_PF_WHOLEROWS;
146 [ # # ]: 0 : pDocShell->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID, nFlags );
147 : 0 : }
148 : :
149 : 0 : void ScUndoCursorAttr::Undo()
150 : : {
151 : 0 : BeginUndo();
152 : 0 : DoChange(pOldPattern, pOldEditData);
153 : :
154 [ # # ]: 0 : if ( bIsAutomatic )
155 : : {
156 : : // wenn automatische Formatierung rueckgaengig gemacht wird,
157 : : // soll auch nicht weiter automatisch formatiert werden:
158 : :
159 : 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
160 [ # # ]: 0 : if (pViewShell)
161 : 0 : pViewShell->ForgetFormatArea();
162 : : }
163 : :
164 : 0 : EndUndo();
165 : 0 : }
166 : :
167 : 0 : void ScUndoCursorAttr::Redo()
168 : : {
169 : 0 : BeginRedo();
170 : 0 : DoChange(pNewPattern, pNewEditData);
171 : 0 : EndRedo();
172 : 0 : }
173 : :
174 : 0 : void ScUndoCursorAttr::Repeat(SfxRepeatTarget& rTarget)
175 : : {
176 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
177 : 0 : ((ScTabViewTarget&)rTarget).GetViewShell()->ApplySelectionPattern( *pApplyPattern );
178 : 0 : }
179 : :
180 : 0 : sal_Bool ScUndoCursorAttr::CanRepeat(SfxRepeatTarget& rTarget) const
181 : : {
182 : 0 : return (rTarget.ISA(ScTabViewTarget));
183 : : }
184 : :
185 : :
186 : : // -----------------------------------------------------------------------
187 : : //
188 : : // Daten eingeben
189 : : //
190 : :
191 : 21 : ScUndoEnterData::ScUndoEnterData( ScDocShell* pNewDocShell,
192 : : SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
193 : : SCTAB nNewCount, SCTAB* pNewTabs, ScBaseCell** ppOldData,
194 : : sal_Bool* pHasForm, sal_uLong* pOldForm,
195 : : const String& rNewStr, EditTextObject* pObj ) :
196 : : ScSimpleUndo( pNewDocShell ),
197 : : aNewString( rNewStr ),
198 : : pTabs( pNewTabs ),
199 : : ppOldCells( ppOldData ),
200 : : pHasFormat( pHasForm ),
201 : : pOldFormats( pOldForm ),
202 : : pNewEditData( pObj ),
203 : : nCol( nNewCol ),
204 : : nRow( nNewRow ),
205 : : nTab( nNewTab ),
206 [ + - ]: 21 : nCount( nNewCount )
207 : : {
208 [ + - ]: 21 : SetChangeTrack();
209 : 21 : }
210 : :
211 [ + - ]: 21 : ScUndoEnterData::~ScUndoEnterData()
212 : : {
213 [ + + ]: 42 : for (sal_uInt16 i=0; i<nCount; i++)
214 [ + + ]: 21 : if (ppOldCells[i])
215 [ + - ]: 5 : ppOldCells[i]->Delete();
216 [ + - ]: 21 : delete[] ppOldCells;
217 : :
218 [ + - ]: 21 : delete[] pHasFormat;
219 [ + - ]: 21 : delete[] pOldFormats;
220 [ + - ]: 21 : delete[] pTabs;
221 : :
222 [ - + ][ # # ]: 21 : delete pNewEditData;
223 [ - + ]: 42 : }
224 : :
225 : 25 : rtl::OUString ScUndoEnterData::GetComment() const
226 : : {
227 : 25 : return ScGlobal::GetRscString( STR_UNDO_ENTERDATA ); // "Eingabe"
228 : : }
229 : :
230 : 0 : void ScUndoEnterData::DoChange() const
231 : : {
232 : : // Zeilenhoehe anpassen
233 : : //! nur wenn noetig (alte oder neue EditZelle, oder Attribute) ??
234 [ # # ]: 0 : for (sal_uInt16 i=0; i<nCount; i++)
235 : 0 : pDocShell->AdjustRowHeight( nRow, nRow, pTabs[i] );
236 : :
237 : 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
238 [ # # ]: 0 : if (pViewShell)
239 : : {
240 : 0 : pViewShell->SetTabNo( nTab );
241 : 0 : pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, false, false );
242 : : }
243 : :
244 : 0 : pDocShell->PostDataChanged();
245 : 0 : }
246 : :
247 : 21 : void ScUndoEnterData::SetChangeTrack()
248 : : {
249 : 21 : ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
250 [ - + ]: 21 : if ( pChangeTrack )
251 : : {
252 : 0 : nEndChangeAction = pChangeTrack->GetActionMax() + 1;
253 : 0 : ScAddress aPos( nCol, nRow, nTab );
254 [ # # ]: 0 : for (sal_uInt16 i=0; i<nCount; i++)
255 : : {
256 : 0 : aPos.SetTab( pTabs[i] );
257 : 0 : sal_uLong nFormat = 0;
258 [ # # ][ # # ]: 0 : if ( pHasFormat && pOldFormats )
259 : : {
260 [ # # ]: 0 : if ( pHasFormat[i] )
261 : 0 : nFormat = pOldFormats[i];
262 : : }
263 [ # # ]: 0 : pChangeTrack->AppendContent( aPos, ppOldCells[i], nFormat );
264 : : }
265 [ # # ]: 0 : if ( nEndChangeAction > pChangeTrack->GetActionMax() )
266 : 0 : nEndChangeAction = 0; // nichts appended
267 : : }
268 : : else
269 : 21 : nEndChangeAction = 0;
270 : 21 : }
271 : :
272 : 0 : void ScUndoEnterData::Undo()
273 : : {
274 : 0 : BeginUndo();
275 : :
276 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
277 [ # # ]: 0 : for (sal_uInt16 i=0; i<nCount; i++)
278 : : {
279 [ # # ]: 0 : ScBaseCell* pNewCell = ppOldCells[i] ? ppOldCells[i]->Clone( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0;
280 : 0 : pDoc->PutCell( nCol, nRow, pTabs[i], pNewCell );
281 : :
282 [ # # ][ # # ]: 0 : if (pHasFormat && pOldFormats)
283 : : {
284 [ # # ]: 0 : if ( pHasFormat[i] )
285 : 0 : pDoc->ApplyAttr( nCol, nRow, pTabs[i],
286 [ # # ]: 0 : SfxUInt32Item( ATTR_VALUE_FORMAT, pOldFormats[i] ) );
287 : : else
288 : : {
289 [ # # ][ # # ]: 0 : ScPatternAttr aPattern( *pDoc->GetPattern( nCol, nRow, pTabs[i] ) );
290 [ # # ]: 0 : aPattern.GetItemSet().ClearItem( ATTR_VALUE_FORMAT );
291 [ # # ][ # # ]: 0 : pDoc->SetPattern( nCol, nRow, pTabs[i], aPattern, sal_True );
292 : : }
293 : : }
294 : 0 : pDocShell->PostPaintCell( nCol, nRow, pTabs[i] );
295 : : }
296 : :
297 : 0 : ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
298 [ # # ][ # # ]: 0 : if ( pChangeTrack && nEndChangeAction >= sal::static_int_cast<sal_uLong>(nCount) )
[ # # ]
299 : 0 : pChangeTrack->Undo( nEndChangeAction - nCount + 1, nEndChangeAction );
300 : :
301 : 0 : DoChange();
302 : 0 : EndUndo();
303 : :
304 : : // #i97876# Spreadsheet data changes are not notified
305 [ # # ]: 0 : ScModelObj* pModelObj = ScModelObj::getImplementation( pDocShell->GetModel() );
306 [ # # ][ # # ]: 0 : if ( pModelObj && pModelObj->HasChangesListeners() )
[ # # ]
307 : : {
308 [ # # ]: 0 : ScRangeList aChangeRanges;
309 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < nCount; ++i )
310 : : {
311 [ # # ]: 0 : aChangeRanges.Append( ScRange( nCol, nRow, pTabs[i] ) );
312 : : }
313 [ # # ][ # # ]: 0 : pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
[ # # ][ # # ]
[ # # ]
314 : : }
315 : 0 : }
316 : :
317 : 0 : void ScUndoEnterData::Redo()
318 : : {
319 : 0 : BeginRedo();
320 : :
321 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
322 [ # # ]: 0 : for (sal_uInt16 i=0; i<nCount; i++)
323 : : {
324 [ # # ]: 0 : if (pNewEditData)
325 : 0 : pDoc->PutCell( nCol, nRow, pTabs[i], new ScEditCell( pNewEditData,
326 [ # # ]: 0 : pDoc, NULL ) );
327 : : else
328 [ # # ]: 0 : pDoc->SetString( nCol, nRow, pTabs[i], aNewString );
329 : 0 : pDocShell->PostPaintCell( nCol, nRow, pTabs[i] );
330 : : }
331 : :
332 : 0 : SetChangeTrack();
333 : :
334 : 0 : DoChange();
335 : 0 : EndRedo();
336 : :
337 : : // #i97876# Spreadsheet data changes are not notified
338 [ # # ]: 0 : ScModelObj* pModelObj = ScModelObj::getImplementation( pDocShell->GetModel() );
339 [ # # ][ # # ]: 0 : if ( pModelObj && pModelObj->HasChangesListeners() )
[ # # ]
340 : : {
341 [ # # ]: 0 : ScRangeList aChangeRanges;
342 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < nCount; ++i )
343 : : {
344 [ # # ]: 0 : aChangeRanges.Append( ScRange( nCol, nRow, pTabs[i] ) );
345 : : }
346 [ # # ][ # # ]: 0 : pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
[ # # ][ # # ]
[ # # ]
347 : : }
348 : 0 : }
349 : :
350 : 0 : void ScUndoEnterData::Repeat(SfxRepeatTarget& rTarget)
351 : : {
352 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
353 : : {
354 [ # # ]: 0 : String aTemp = aNewString;
355 [ # # ][ # # ]: 0 : ((ScTabViewTarget&)rTarget).GetViewShell()->EnterDataAtCursor( aTemp );
356 : : }
357 : 0 : }
358 : :
359 : 2 : sal_Bool ScUndoEnterData::CanRepeat(SfxRepeatTarget& rTarget) const
360 : : {
361 : 2 : return (rTarget.ISA(ScTabViewTarget));
362 : : }
363 : :
364 : :
365 : : // -----------------------------------------------------------------------
366 : : //
367 : : // Wert aendern
368 : : //
369 : :
370 : 0 : ScUndoEnterValue::ScUndoEnterValue( ScDocShell* pNewDocShell, const ScAddress& rNewPos,
371 : : ScBaseCell* pUndoCell, double nVal, sal_Bool bHeight ) :
372 : : ScSimpleUndo( pNewDocShell ),
373 : : aPos ( rNewPos ),
374 : : pOldCell ( pUndoCell ),
375 : : nValue ( nVal ),
376 : 0 : bNeedHeight ( bHeight )
377 : : {
378 [ # # ]: 0 : SetChangeTrack();
379 : 0 : }
380 : :
381 : 0 : ScUndoEnterValue::~ScUndoEnterValue()
382 : : {
383 [ # # ]: 0 : if (pOldCell)
384 [ # # ]: 0 : pOldCell->Delete();
385 [ # # ]: 0 : }
386 : :
387 : 0 : rtl::OUString ScUndoEnterValue::GetComment() const
388 : : {
389 : 0 : return ScGlobal::GetRscString( STR_UNDO_ENTERDATA ); // "Eingabe"
390 : : }
391 : :
392 : 0 : void ScUndoEnterValue::SetChangeTrack()
393 : : {
394 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
395 : 0 : ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
396 [ # # ]: 0 : if ( pChangeTrack )
397 : : {
398 : 0 : nEndChangeAction = pChangeTrack->GetActionMax() + 1;
399 : 0 : pChangeTrack->AppendContent( aPos, pOldCell );
400 [ # # ]: 0 : if ( nEndChangeAction > pChangeTrack->GetActionMax() )
401 : 0 : nEndChangeAction = 0; // nichts appended
402 : : }
403 : : else
404 : 0 : nEndChangeAction = 0;
405 : 0 : }
406 : :
407 : 0 : void ScUndoEnterValue::Undo()
408 : : {
409 : 0 : BeginUndo();
410 : :
411 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
412 [ # # ]: 0 : ScBaseCell* pNewCell = pOldCell ? pOldCell->Clone( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0;
413 : :
414 : 0 : pDoc->PutCell( aPos, pNewCell );
415 : :
416 : 0 : pDocShell->PostPaintCell( aPos );
417 : :
418 : 0 : ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
419 [ # # ]: 0 : if ( pChangeTrack )
420 : 0 : pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
421 : :
422 : 0 : EndUndo();
423 : 0 : }
424 : :
425 : 0 : void ScUndoEnterValue::Redo()
426 : : {
427 : 0 : BeginRedo();
428 : :
429 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
430 : 0 : pDoc->SetValue( aPos.Col(), aPos.Row(), aPos.Tab(), nValue );
431 : 0 : pDocShell->PostPaintCell( aPos );
432 : :
433 : 0 : SetChangeTrack();
434 : :
435 : 0 : EndRedo();
436 : 0 : }
437 : :
438 : 0 : void ScUndoEnterValue::Repeat(SfxRepeatTarget& /* rTarget */)
439 : : {
440 : : // gippsnich
441 : 0 : }
442 : :
443 : 0 : sal_Bool ScUndoEnterValue::CanRepeat(SfxRepeatTarget& /* rTarget */) const
444 : : {
445 : 0 : return false;
446 : : }
447 : :
448 : :
449 : : // -----------------------------------------------------------------------
450 : : //
451 : : // Beliebige Zelle eingeben
452 : : //
453 : :
454 : 2694 : ScUndoPutCell::ScUndoPutCell( ScDocShell* pNewDocShell, const ScAddress& rNewPos,
455 : : ScBaseCell* pUndoCell, ScBaseCell* pRedoCell, sal_Bool bHeight ) :
456 : : ScSimpleUndo( pNewDocShell ),
457 : : aPos ( rNewPos ),
458 : : pOldCell ( pUndoCell ),
459 : : pEnteredCell( pRedoCell ),
460 : 2694 : bNeedHeight ( bHeight )
461 : : {
462 [ + - ]: 2694 : SetChangeTrack();
463 : 2694 : }
464 : :
465 : 2694 : ScUndoPutCell::~ScUndoPutCell()
466 : : {
467 [ + + ]: 2694 : if (pOldCell)
468 [ + - ]: 336 : pOldCell->Delete();
469 [ + - ]: 2694 : if (pEnteredCell)
470 [ + - ]: 2694 : pEnteredCell->Delete();
471 [ - + ]: 5388 : }
472 : :
473 : 2836 : rtl::OUString ScUndoPutCell::GetComment() const
474 : : {
475 : 2836 : return ScGlobal::GetRscString( STR_UNDO_ENTERDATA ); // "Eingabe"
476 : : }
477 : :
478 : 2694 : void ScUndoPutCell::SetChangeTrack()
479 : : {
480 : 2694 : ScDocument* pDoc = pDocShell->GetDocument();
481 : 2694 : ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
482 [ - + ]: 2694 : if ( pChangeTrack )
483 : : {
484 : 0 : nEndChangeAction = pChangeTrack->GetActionMax() + 1;
485 : 0 : pChangeTrack->AppendContent( aPos, pOldCell );
486 [ # # ]: 0 : if ( nEndChangeAction > pChangeTrack->GetActionMax() )
487 : 0 : nEndChangeAction = 0; // nichts appended
488 : : }
489 : : else
490 : 2694 : nEndChangeAction = 0;
491 : 2694 : }
492 : :
493 : 0 : void ScUndoPutCell::Undo()
494 : : {
495 : 0 : BeginUndo();
496 : :
497 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
498 [ # # ]: 0 : ScBaseCell* pNewCell = pOldCell ? pOldCell->Clone( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0;
499 : :
500 : 0 : pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell );
501 : :
502 : 0 : pDocShell->PostPaintCell( aPos );
503 : :
504 : 0 : ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
505 [ # # ]: 0 : if ( pChangeTrack )
506 : 0 : pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
507 : :
508 : 0 : EndUndo();
509 : 0 : }
510 : :
511 : 0 : void ScUndoPutCell::Redo()
512 : : {
513 : 0 : BeginRedo();
514 : :
515 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
516 [ # # ]: 0 : ScBaseCell* pNewCell = pEnteredCell ? pEnteredCell->Clone( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0;
517 : :
518 : 0 : pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell );
519 : :
520 : 0 : pDocShell->PostPaintCell( aPos );
521 : :
522 : 0 : SetChangeTrack();
523 : :
524 : 0 : EndRedo();
525 : 0 : }
526 : :
527 : 0 : void ScUndoPutCell::Repeat(SfxRepeatTarget& /* rTarget */)
528 : : {
529 : : // gippsnich
530 : 0 : }
531 : :
532 : 142 : sal_Bool ScUndoPutCell::CanRepeat(SfxRepeatTarget& /* rTarget */) const
533 : : {
534 : 142 : return false;
535 : : }
536 : :
537 : :
538 : : // -----------------------------------------------------------------------
539 : : //
540 : : // Seitenumbrueche
541 : : //
542 : :
543 : 0 : ScUndoPageBreak::ScUndoPageBreak( ScDocShell* pNewDocShell,
544 : : SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
545 : : sal_Bool bNewColumn, sal_Bool bNewInsert ) :
546 : : ScSimpleUndo( pNewDocShell ),
547 : : nCol( nNewCol ),
548 : : nRow( nNewRow ),
549 : : nTab( nNewTab ),
550 : : bColumn( bNewColumn ),
551 : 0 : bInsert( bNewInsert )
552 : : {
553 : 0 : }
554 : :
555 : 0 : ScUndoPageBreak::~ScUndoPageBreak()
556 : : {
557 [ # # ]: 0 : }
558 : :
559 : 0 : rtl::OUString ScUndoPageBreak::GetComment() const
560 : : {
561 : : //"Spaltenumbruch" | "Zeilenumbruch" "einfuegen" | "loeschen"
562 : : return String ( bColumn ?
563 : : ( bInsert ?
564 : : ScGlobal::GetRscString( STR_UNDO_INSCOLBREAK ) :
565 : : ScGlobal::GetRscString( STR_UNDO_DELCOLBREAK )
566 : : ) :
567 : : ( bInsert ?
568 : : ScGlobal::GetRscString( STR_UNDO_INSROWBREAK ) :
569 : : ScGlobal::GetRscString( STR_UNDO_DELROWBREAK )
570 [ # # ][ # # ]: 0 : ) );
[ # # ][ # # ]
571 : : }
572 : :
573 : 0 : void ScUndoPageBreak::DoChange( sal_Bool bInsertP ) const
574 : : {
575 : 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
576 : :
577 [ # # ]: 0 : if (pViewShell)
578 : : {
579 : 0 : pViewShell->SetTabNo( nTab );
580 : 0 : pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, false, false );
581 : :
582 [ # # ]: 0 : if (bInsertP)
583 : 0 : pViewShell->InsertPageBreak(bColumn, false);
584 : : else
585 : 0 : pViewShell->DeletePageBreak(bColumn, false);
586 : :
587 : 0 : pDocShell->GetDocument()->InvalidatePageBreaks(nTab);
588 : : }
589 : 0 : }
590 : :
591 : 0 : void ScUndoPageBreak::Undo()
592 : : {
593 : 0 : BeginUndo();
594 : 0 : DoChange(!bInsert);
595 : 0 : EndUndo();
596 : 0 : }
597 : :
598 : 0 : void ScUndoPageBreak::Redo()
599 : : {
600 : 0 : BeginRedo();
601 : 0 : DoChange(bInsert);
602 : 0 : EndRedo();
603 : 0 : }
604 : :
605 : 0 : void ScUndoPageBreak::Repeat(SfxRepeatTarget& rTarget)
606 : : {
607 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
608 : : {
609 : 0 : ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
610 : :
611 [ # # ]: 0 : if (bInsert)
612 : 0 : rViewShell.InsertPageBreak(bColumn, sal_True);
613 : : else
614 : 0 : rViewShell.DeletePageBreak(bColumn, sal_True);
615 : : }
616 : 0 : }
617 : :
618 : 0 : sal_Bool ScUndoPageBreak::CanRepeat(SfxRepeatTarget& rTarget) const
619 : : {
620 : 0 : return (rTarget.ISA(ScTabViewTarget));
621 : : }
622 : :
623 : : // -----------------------------------------------------------------------
624 : : //
625 : : // Druck-Skalierung
626 : : //
627 : :
628 : 0 : ScUndoPrintZoom::ScUndoPrintZoom( ScDocShell* pNewDocShell,
629 : : SCTAB nT, sal_uInt16 nOS, sal_uInt16 nOP, sal_uInt16 nNS, sal_uInt16 nNP ) :
630 : : ScSimpleUndo( pNewDocShell ),
631 : : nTab( nT ),
632 : : nOldScale( nOS ),
633 : : nOldPages( nOP ),
634 : : nNewScale( nNS ),
635 : 0 : nNewPages( nNP )
636 : : {
637 : 0 : }
638 : :
639 : 0 : ScUndoPrintZoom::~ScUndoPrintZoom()
640 : : {
641 [ # # ]: 0 : }
642 : :
643 : 0 : rtl::OUString ScUndoPrintZoom::GetComment() const
644 : : {
645 : 0 : return ScGlobal::GetRscString( STR_UNDO_PRINTSCALE );
646 : : }
647 : :
648 : 0 : void ScUndoPrintZoom::DoChange( sal_Bool bUndo )
649 : : {
650 [ # # ]: 0 : sal_uInt16 nScale = bUndo ? nOldScale : nNewScale;
651 [ # # ]: 0 : sal_uInt16 nPages = bUndo ? nOldPages : nNewPages;
652 : :
653 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
654 [ # # ][ # # ]: 0 : String aStyleName = pDoc->GetPageStyle( nTab );
655 [ # # ]: 0 : ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
656 [ # # ]: 0 : SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SFX_STYLE_FAMILY_PAGE );
657 : : OSL_ENSURE( pStyleSheet, "PageStyle not found" );
658 [ # # ]: 0 : if ( pStyleSheet )
659 : : {
660 [ # # ]: 0 : SfxItemSet& rSet = pStyleSheet->GetItemSet();
661 [ # # ][ # # ]: 0 : rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nScale ) );
[ # # ]
662 [ # # ][ # # ]: 0 : rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, nPages ) );
[ # # ]
663 : :
664 [ # # ][ # # ]: 0 : ScPrintFunc aPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab );
665 [ # # ][ # # ]: 0 : aPrintFunc.UpdatePages();
666 [ # # ]: 0 : }
667 : 0 : }
668 : :
669 : 0 : void ScUndoPrintZoom::Undo()
670 : : {
671 : 0 : BeginUndo();
672 : 0 : DoChange(sal_True);
673 : 0 : EndUndo();
674 : 0 : }
675 : :
676 : 0 : void ScUndoPrintZoom::Redo()
677 : : {
678 : 0 : BeginRedo();
679 : 0 : DoChange(false);
680 : 0 : EndRedo();
681 : 0 : }
682 : :
683 : 0 : void ScUndoPrintZoom::Repeat(SfxRepeatTarget& rTarget)
684 : : {
685 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
686 : : {
687 : 0 : ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
688 : 0 : ScViewData* pViewData = rViewShell.GetViewData();
689 : 0 : pViewData->GetDocShell()->SetPrintZoom( pViewData->GetTabNo(), nNewScale, nNewPages );
690 : : }
691 : 0 : }
692 : :
693 : 0 : sal_Bool ScUndoPrintZoom::CanRepeat(SfxRepeatTarget& rTarget) const
694 : : {
695 : 0 : return (rTarget.ISA(ScTabViewTarget));
696 : : }
697 : :
698 : :
699 : : // -----------------------------------------------------------------------
700 : : //
701 : : // Thesaurus
702 : : //
703 : :
704 : 0 : ScUndoThesaurus::ScUndoThesaurus( ScDocShell* pNewDocShell,
705 : : SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
706 : : const String& rNewUndoStr, const EditTextObject* pUndoTObj,
707 : : const String& rNewRedoStr, const EditTextObject* pRedoTObj) :
708 : : ScSimpleUndo( pNewDocShell ),
709 : : nCol( nNewCol ),
710 : : nRow( nNewRow ),
711 : : nTab( nNewTab ),
712 : : aUndoStr( rNewUndoStr ),
713 [ # # ][ # # ]: 0 : aRedoStr( rNewRedoStr )
714 : : {
715 [ # # ][ # # ]: 0 : pUndoTObject = (pUndoTObj) ? pUndoTObj->Clone() : NULL;
716 [ # # ][ # # ]: 0 : pRedoTObject = (pRedoTObj) ? pRedoTObj->Clone() : NULL;
717 : :
718 : : ScBaseCell* pOldCell;
719 [ # # ]: 0 : if ( pUndoTObject )
720 [ # # ][ # # ]: 0 : pOldCell = new ScEditCell( pUndoTObject, pDocShell->GetDocument(), NULL );
721 : : else
722 [ # # ][ # # ]: 0 : pOldCell = new ScStringCell( aUndoStr );
[ # # ]
723 [ # # ]: 0 : SetChangeTrack( pOldCell );
724 [ # # ]: 0 : pOldCell->Delete();
725 : 0 : }
726 : :
727 [ # # ][ # # ]: 0 : ScUndoThesaurus::~ScUndoThesaurus()
728 : : {
729 [ # # ][ # # ]: 0 : delete pUndoTObject;
730 [ # # ][ # # ]: 0 : delete pRedoTObject;
731 [ # # ]: 0 : }
732 : :
733 : 0 : rtl::OUString ScUndoThesaurus::GetComment() const
734 : : {
735 : 0 : return ScGlobal::GetRscString( STR_UNDO_THESAURUS ); // "Thesaurus"
736 : : }
737 : :
738 : 0 : void ScUndoThesaurus::SetChangeTrack( ScBaseCell* pOldCell )
739 : : {
740 : 0 : ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
741 [ # # ]: 0 : if ( pChangeTrack )
742 : : {
743 : 0 : nEndChangeAction = pChangeTrack->GetActionMax() + 1;
744 [ # # ]: 0 : pChangeTrack->AppendContent( ScAddress( nCol, nRow, nTab ), pOldCell );
745 [ # # ]: 0 : if ( nEndChangeAction > pChangeTrack->GetActionMax() )
746 : 0 : nEndChangeAction = 0; // nichts appended
747 : : }
748 : : else
749 : 0 : nEndChangeAction = 0;
750 : 0 : }
751 : :
752 : 0 : void ScUndoThesaurus::DoChange( sal_Bool bUndo, const String& rStr,
753 : : const EditTextObject* pTObj )
754 : : {
755 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
756 : :
757 : 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
758 [ # # ]: 0 : if (pViewShell)
759 : : {
760 : 0 : pViewShell->SetTabNo( nTab );
761 : 0 : pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, false, false );
762 : : }
763 : :
764 [ # # ]: 0 : if (pTObj)
765 : : {
766 : : ScBaseCell* pCell;
767 [ # # ]: 0 : pDoc->GetCell( nCol, nRow, nTab, pCell );
768 [ # # ]: 0 : if (pCell)
769 : : {
770 [ # # ]: 0 : if (pCell->GetCellType() == CELLTYPE_EDIT )
771 : : {
772 [ # # ][ # # ]: 0 : ScEditCell* pNewCell = new ScEditCell( pTObj, pDoc, NULL );
773 [ # # ]: 0 : pDoc->PutCell( nCol, nRow, nTab, pNewCell );
774 [ # # ]: 0 : if ( !bUndo )
775 [ # # ]: 0 : SetChangeTrack( pCell );
776 : : }
777 : : else
778 : : {
779 : : OSL_FAIL("Nicht CELLTYPE_EDIT bei Un/RedoThesaurus");
780 : : }
781 : : }
782 : : }
783 : : else
784 : : {
785 : 0 : ScBaseCell* pCell = NULL;
786 [ # # ]: 0 : if ( !bUndo )
787 [ # # ]: 0 : pDoc->GetCell( nCol, nRow, nTab, pCell );
788 [ # # ][ # # ]: 0 : pDoc->SetString( nCol, nRow, nTab, rStr );
789 [ # # ]: 0 : if ( !bUndo )
790 [ # # ]: 0 : SetChangeTrack( pCell );
791 : : }
792 : :
793 : 0 : pDocShell->PostPaintCell( nCol, nRow, nTab );
794 : 0 : }
795 : :
796 : 0 : void ScUndoThesaurus::Undo()
797 : : {
798 : 0 : BeginUndo();
799 : 0 : DoChange( sal_True, aUndoStr, pUndoTObject );
800 : 0 : ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
801 [ # # ]: 0 : if ( pChangeTrack )
802 : 0 : pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
803 : 0 : EndUndo();
804 : 0 : }
805 : :
806 : 0 : void ScUndoThesaurus::Redo()
807 : : {
808 : 0 : BeginRedo();
809 : 0 : DoChange( false, aRedoStr, pRedoTObject );
810 : 0 : EndRedo();
811 : 0 : }
812 : :
813 : 0 : void ScUndoThesaurus::Repeat(SfxRepeatTarget& rTarget)
814 : : {
815 [ # # ]: 0 : if (rTarget.ISA(ScTabViewTarget))
816 : 0 : ((ScTabViewTarget&)rTarget).GetViewShell()->DoThesaurus( sal_True );
817 : 0 : }
818 : :
819 : 0 : sal_Bool ScUndoThesaurus::CanRepeat(SfxRepeatTarget& rTarget) const
820 : : {
821 : 0 : return (rTarget.ISA(ScTabViewTarget));
822 : : }
823 : :
824 : :
825 : : // ============================================================================
826 : :
827 : 0 : ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rPos,
828 : : const ScNoteData& rNoteData, bool bInsert, SdrUndoAction* pDrawUndo ) :
829 : : ScSimpleUndo( &rDocShell ),
830 : : maPos( rPos ),
831 [ # # ][ # # ]: 0 : mpDrawUndo( pDrawUndo )
832 : : {
833 : : OSL_ENSURE( rNoteData.mpCaption, "ScUndoReplaceNote::ScUndoReplaceNote - missing note caption" );
834 [ # # ][ # # ]: 0 : (bInsert ? maNewData : maOldData) = rNoteData;
[ # # ]
835 : 0 : }
836 : :
837 : 2 : ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rPos,
838 : : const ScNoteData& rOldData, const ScNoteData& rNewData, SdrUndoAction* pDrawUndo ) :
839 : : ScSimpleUndo( &rDocShell ),
840 : : maPos( rPos ),
841 : : maOldData( rOldData ),
842 : : maNewData( rNewData ),
843 [ + - ][ + - ]: 2 : mpDrawUndo( pDrawUndo )
844 : : {
845 : : OSL_ENSURE( maOldData.mpCaption || maNewData.mpCaption, "ScUndoReplaceNote::ScUndoReplaceNote - missing note captions" );
846 : : OSL_ENSURE( !maOldData.mxInitData.get() && !maNewData.mxInitData.get(), "ScUndoReplaceNote::ScUndoReplaceNote - unexpected unitialized note" );
847 : 2 : }
848 : :
849 [ + - ][ + - ]: 2 : ScUndoReplaceNote::~ScUndoReplaceNote()
850 : : {
851 [ + - ]: 2 : DeleteSdrUndoAction( mpDrawUndo );
852 [ - + ]: 4 : }
853 : :
854 : 0 : void ScUndoReplaceNote::Undo()
855 : : {
856 : 0 : BeginUndo();
857 : 0 : DoSdrUndoAction( mpDrawUndo, pDocShell->GetDocument() );
858 : : /* Undo insert -> remove new note.
859 : : Undo remove -> insert old note.
860 : : Undo replace -> remove new note, insert old note. */
861 : 0 : DoRemoveNote( maNewData );
862 : 0 : DoInsertNote( maOldData );
863 : 0 : pDocShell->PostPaintCell( maPos );
864 : 0 : EndUndo();
865 : 0 : }
866 : :
867 : 0 : void ScUndoReplaceNote::Redo()
868 : : {
869 : 0 : BeginRedo();
870 : 0 : RedoSdrUndoAction( mpDrawUndo );
871 : : /* Redo insert -> insert new note.
872 : : Redo remove -> remove old note.
873 : : Redo replace -> remove old note, insert new note. */
874 : 0 : DoRemoveNote( maOldData );
875 : 0 : DoInsertNote( maNewData );
876 : 0 : pDocShell->PostPaintCell( maPos );
877 : 0 : EndRedo();
878 : 0 : }
879 : :
880 : 0 : void ScUndoReplaceNote::Repeat( SfxRepeatTarget& /*rTarget*/ )
881 : : {
882 : 0 : }
883 : :
884 : 2 : sal_Bool ScUndoReplaceNote::CanRepeat( SfxRepeatTarget& /*rTarget*/ ) const
885 : : {
886 : 2 : return false;
887 : : }
888 : :
889 : 4 : rtl::OUString ScUndoReplaceNote::GetComment() const
890 : : {
891 : : return ScGlobal::GetRscString( maNewData.mpCaption ?
892 [ + - ][ - + ]: 4 : (maOldData.mpCaption ? STR_UNDO_EDITNOTE : STR_UNDO_INSERTNOTE) : STR_UNDO_DELETENOTE );
893 : : }
894 : :
895 : 0 : void ScUndoReplaceNote::DoInsertNote( const ScNoteData& rNoteData )
896 : : {
897 [ # # ]: 0 : if( rNoteData.mpCaption )
898 : : {
899 : 0 : ScDocument& rDoc = *pDocShell->GetDocument();
900 : : OSL_ENSURE( !rDoc.GetNotes( maPos.Tab() )->findByAddress(maPos), "ScUndoReplaceNote::DoInsertNote - unexpected cell note" );
901 [ # # ]: 0 : ScPostIt* pNote = new ScPostIt( rDoc, maPos, rNoteData, false );
902 : 0 : rDoc.GetNotes(maPos.Tab())->insert( maPos, pNote );
903 : : }
904 : 0 : }
905 : :
906 : 0 : void ScUndoReplaceNote::DoRemoveNote( const ScNoteData& rNoteData )
907 : : {
908 [ # # ]: 0 : if( rNoteData.mpCaption )
909 : : {
910 : 0 : ScDocument& rDoc = *pDocShell->GetDocument();
911 : : OSL_ENSURE( rDoc.GetNotes( maPos.Tab() )->findByAddress(maPos), "ScUndoReplaceNote::DoRemoveNote - missing cell note" );
912 [ # # ]: 0 : if( ScPostIt* pNote = rDoc.GetNotes(maPos.Tab())->ReleaseNote( maPos ) )
913 : : {
914 : : /* Forget pointer to caption object to suppress removing the
915 : : caption object from the drawing layer while deleting pNote
916 : : (removing the caption is done by a drawing undo action). */
917 : 0 : pNote->ForgetCaption();
918 [ # # ]: 0 : delete pNote;
919 : : }
920 : : }
921 : 0 : }
922 : :
923 : : // ============================================================================
924 : :
925 : 0 : ScUndoShowHideNote::ScUndoShowHideNote( ScDocShell& rDocShell, const ScAddress& rPos, bool bShow ) :
926 : : ScSimpleUndo( &rDocShell ),
927 : : maPos( rPos ),
928 : 0 : mbShown( bShow )
929 : : {
930 : 0 : }
931 : :
932 : 0 : ScUndoShowHideNote::~ScUndoShowHideNote()
933 : : {
934 [ # # ]: 0 : }
935 : :
936 : 0 : void ScUndoShowHideNote::Undo()
937 : : {
938 : 0 : BeginUndo();
939 [ # # ]: 0 : if( ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( maPos.Tab() )->findByAddress(maPos) )
940 : 0 : pNote->ShowCaption( maPos, !mbShown );
941 : 0 : EndUndo();
942 : 0 : }
943 : :
944 : 0 : void ScUndoShowHideNote::Redo()
945 : : {
946 : 0 : BeginRedo();
947 [ # # ]: 0 : if( ScPostIt* pNote = pDocShell->GetDocument()->GetNotes( maPos.Tab() )->findByAddress(maPos) )
948 : 0 : pNote->ShowCaption( maPos, mbShown );
949 : 0 : EndRedo();
950 : 0 : }
951 : :
952 : 0 : void ScUndoShowHideNote::Repeat( SfxRepeatTarget& /*rTarget*/ )
953 : : {
954 : 0 : }
955 : :
956 : 0 : sal_Bool ScUndoShowHideNote::CanRepeat( SfxRepeatTarget& /*rTarget*/ ) const
957 : : {
958 : 0 : return false;
959 : : }
960 : :
961 : 0 : rtl::OUString ScUndoShowHideNote::GetComment() const
962 : : {
963 [ # # ]: 0 : return ScGlobal::GetRscString( mbShown ? STR_UNDO_SHOWNOTE : STR_UNDO_HIDENOTE );
964 : : }
965 : :
966 : : // ============================================================================
967 : :
968 : : // -----------------------------------------------------------------------
969 : : //
970 : : // Detektiv
971 : : //
972 : :
973 : 1 : ScUndoDetective::ScUndoDetective( ScDocShell* pNewDocShell,
974 : : SdrUndoAction* pDraw, const ScDetOpData* pOperation,
975 : : ScDetOpList* pUndoList ) :
976 : : ScSimpleUndo( pNewDocShell ),
977 : : pOldList ( pUndoList ),
978 : : nAction ( 0 ),
979 : 1 : pDrawUndo ( pDraw )
980 : : {
981 : 1 : bIsDelete = ( pOperation == NULL );
982 [ + - ]: 1 : if (!bIsDelete)
983 : : {
984 : 1 : nAction = (sal_uInt16) pOperation->GetOperation();
985 : 1 : aPos = pOperation->GetPos();
986 : : }
987 : 1 : }
988 : :
989 : 1 : ScUndoDetective::~ScUndoDetective()
990 : : {
991 [ + - ]: 1 : DeleteSdrUndoAction( pDrawUndo );
992 [ - + ][ # # ]: 1 : delete pOldList;
993 [ - + ]: 2 : }
994 : :
995 : 1 : rtl::OUString ScUndoDetective::GetComment() const
996 : : {
997 : 1 : sal_uInt16 nId = STR_UNDO_DETDELALL;
998 [ + - ]: 1 : if ( !bIsDelete )
999 [ - - + - : 1 : switch ( (ScDetOpType) nAction )
- - ]
1000 : : {
1001 : 0 : case SCDETOP_ADDSUCC: nId = STR_UNDO_DETADDSUCC; break;
1002 : 0 : case SCDETOP_DELSUCC: nId = STR_UNDO_DETDELSUCC; break;
1003 : 1 : case SCDETOP_ADDPRED: nId = STR_UNDO_DETADDPRED; break;
1004 : 0 : case SCDETOP_DELPRED: nId = STR_UNDO_DETDELPRED; break;
1005 : 1 : case SCDETOP_ADDERROR: nId = STR_UNDO_DETADDERROR; break;
1006 : : }
1007 : :
1008 : 1 : return ScGlobal::GetRscString( nId );
1009 : : }
1010 : :
1011 : :
1012 : 0 : void ScUndoDetective::Undo()
1013 : : {
1014 : 0 : BeginUndo();
1015 : :
1016 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1017 : 0 : DoSdrUndoAction(pDrawUndo, pDoc);
1018 : :
1019 [ # # ]: 0 : if (bIsDelete)
1020 : : {
1021 [ # # ]: 0 : if ( pOldList )
1022 [ # # ]: 0 : pDoc->SetDetOpList( new ScDetOpList(*pOldList) );
1023 : : }
1024 : : else
1025 : : {
1026 : : // Eintrag aus der Liste loeschen
1027 : :
1028 : 0 : ScDetOpList* pList = pDoc->GetDetOpList();
1029 [ # # ][ # # ]: 0 : if (pList && pList->Count())
[ # # ]
1030 : : {
1031 : 0 : ScDetOpDataVector& rVec = pList->GetDataVector();
1032 [ # # ][ # # ]: 0 : ScDetOpDataVector::iterator it = rVec.begin() + rVec.size() - 1;
[ # # ]
1033 [ # # ][ # # ]: 0 : if ( it->GetOperation() == (ScDetOpType) nAction && it->GetPos() == aPos )
[ # # ][ # # ]
[ # # ]
1034 [ # # ]: 0 : rVec.erase( it);
1035 : : else
1036 : : {
1037 : : OSL_FAIL("Detektiv-Eintrag in der Liste nicht gefunden");
1038 : : }
1039 : : }
1040 : : }
1041 : :
1042 : 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1043 [ # # ]: 0 : if (pViewShell)
1044 : 0 : pViewShell->RecalcPPT(); //! use broadcast instead?
1045 : :
1046 : 0 : EndUndo();
1047 : 0 : }
1048 : :
1049 : 0 : void ScUndoDetective::Redo()
1050 : : {
1051 : 0 : BeginRedo();
1052 : :
1053 : 0 : RedoSdrUndoAction(pDrawUndo);
1054 : :
1055 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1056 : :
1057 [ # # ]: 0 : if (bIsDelete)
1058 : 0 : pDoc->ClearDetectiveOperations();
1059 : : else
1060 [ # # ]: 0 : pDoc->AddDetectiveOperation( ScDetOpData( aPos, (ScDetOpType) nAction ) );
1061 : :
1062 : 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1063 [ # # ]: 0 : if (pViewShell)
1064 : 0 : pViewShell->RecalcPPT(); //! use broadcast instead?
1065 : :
1066 : 0 : EndRedo();
1067 : 0 : }
1068 : :
1069 : 0 : void ScUndoDetective::Repeat(SfxRepeatTarget& /* rTarget */)
1070 : : {
1071 : : // hammanich
1072 : 0 : }
1073 : :
1074 : 0 : sal_Bool ScUndoDetective::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1075 : : {
1076 : 0 : return false;
1077 : : }
1078 : :
1079 : : // -----------------------------------------------------------------------
1080 : : //
1081 : : // Benannte Bereiche
1082 : : //
1083 : :
1084 : 39 : ScUndoRangeNames::ScUndoRangeNames( ScDocShell* pNewDocShell,
1085 : : ScRangeName* pOld, ScRangeName* pNew, SCTAB nTab ) :
1086 : : ScSimpleUndo( pNewDocShell ),
1087 : : pOldRanges ( pOld ),
1088 : : pNewRanges ( pNew ),
1089 : 39 : mnTab ( nTab )
1090 : : {
1091 : 39 : }
1092 : :
1093 : 39 : ScUndoRangeNames::~ScUndoRangeNames()
1094 : : {
1095 [ + - ][ + - ]: 39 : delete pOldRanges;
1096 [ + - ][ + - ]: 39 : delete pNewRanges;
1097 [ - + ]: 78 : }
1098 : :
1099 : 39 : rtl::OUString ScUndoRangeNames::GetComment() const
1100 : : {
1101 : 39 : return ScGlobal::GetRscString( STR_UNDO_RANGENAMES );
1102 : : }
1103 : :
1104 : 0 : void ScUndoRangeNames::DoChange( sal_Bool bUndo )
1105 : : {
1106 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
1107 : 0 : pDoc->CompileNameFormula( sal_True ); // CreateFormulaString
1108 : :
1109 [ # # ]: 0 : if ( bUndo )
1110 : : {
1111 [ # # ]: 0 : if (mnTab >= 0)
1112 [ # # ]: 0 : pDoc->SetRangeName( mnTab, new ScRangeName( *pOldRanges ) );
1113 : : else
1114 [ # # ]: 0 : pDoc->SetRangeName( new ScRangeName( *pOldRanges ) );
1115 : : }
1116 : : else
1117 : : {
1118 [ # # ]: 0 : if (mnTab >= 0)
1119 [ # # ]: 0 : pDoc->SetRangeName( mnTab, new ScRangeName( *pNewRanges ) );
1120 : : else
1121 [ # # ]: 0 : pDoc->SetRangeName( new ScRangeName( *pNewRanges ) );
1122 : : }
1123 : :
1124 : 0 : pDoc->CompileNameFormula( false ); // CompileFormulaString
1125 : :
1126 [ # # ][ # # ]: 0 : SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
1127 : 0 : }
1128 : :
1129 : 0 : void ScUndoRangeNames::Undo()
1130 : : {
1131 : 0 : BeginUndo();
1132 : 0 : DoChange( sal_True );
1133 : 0 : EndUndo();
1134 : 0 : }
1135 : :
1136 : 0 : void ScUndoRangeNames::Redo()
1137 : : {
1138 : 0 : BeginRedo();
1139 : 0 : DoChange( false );
1140 : 0 : EndRedo();
1141 : 0 : }
1142 : :
1143 : 0 : void ScUndoRangeNames::Repeat(SfxRepeatTarget& /* rTarget */)
1144 : : {
1145 : : // hammanich
1146 : 0 : }
1147 : :
1148 : 0 : sal_Bool ScUndoRangeNames::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1149 : : {
1150 : 0 : return false;
1151 : : }
1152 : :
1153 : :
1154 : :
1155 : :
1156 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|