Coverage Report

Created: 2025-11-16 09:57

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