Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/view/tabvwsh3.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
#include <sfx2/bindings.hxx>
20
#include <sfx2/dispatch.hxx>
21
#include <sfx2/passwd.hxx>
22
#include <sfx2/request.hxx>
23
#include <sfx2/sidebar/Sidebar.hxx>
24
#include <svl/ptitem.hxx>
25
#include <svl/stritem.hxx>
26
#include <tools/urlobj.hxx>
27
#include <sfx2/objface.hxx>
28
#include <vcl/svapp.hxx>
29
#include <vcl/vclenum.hxx>
30
#include <vcl/uitest/logger.hxx>
31
#include <vcl/uitest/eventdescription.hxx>
32
#include <vcl/weld/MessageDialog.hxx>
33
34
#include <globstr.hrc>
35
#include <strings.hrc>
36
#include <scmod.hxx>
37
#include <appoptio.hxx>
38
#include <tabvwsh.hxx>
39
#include <document.hxx>
40
#include <sc.hrc>
41
#include <helpids.h>
42
#include <inputwin.hxx>
43
#include <scresid.hxx>
44
#include <docsh.hxx>
45
#include <rangeutl.hxx>
46
#include <reffact.hxx>
47
#include <tabprotection.hxx>
48
#include <protectiondlg.hxx>
49
#include <duplicaterecordsdlg.hxx>
50
#include <markdata.hxx>
51
#include <cellsuno.hxx>
52
53
#include <svl/ilstitem.hxx>
54
#include <vector>
55
56
#include <svx/zoomslideritem.hxx>
57
#include <svx/svxdlg.hxx>
58
#include <svx/ColorSets.hxx>
59
#include <comphelper/lok.hxx>
60
#include <comphelper/string.hxx>
61
#include <com/sun/star/uno/Reference.h>
62
#include <com/sun/star/sheet/XCellRangeData.hpp>
63
#include <sfx2/lokhelper.hxx>
64
#include <scabstdlg.hxx>
65
#include <officecfg/Office/Calc.hxx>
66
67
#include <basegfx/utils/zoomtools.hxx>
68
69
#include <svx/dialog/ThemeDialog.hxx>
70
#include <ThemeColorChanger.hxx>
71
#include <dialogs/SelectSheetViewDialog.hxx>
72
73
namespace
74
{
75
    void collectUIInformation(const OUString& aZoom)
76
0
    {
77
0
        EventDescription aDescription;
78
0
        aDescription.aID = "grid_window";
79
0
        aDescription.aParameters = {{"ZOOM", aZoom}};
80
0
        aDescription.aAction = "SET";
81
0
        aDescription.aKeyWord = "ScGridWinUIObject";
82
0
        aDescription.aParent = "MainWindow";
83
0
        UITestLogger::getInstance().logEvent(aDescription);
84
0
    }
85
86
    enum class DetectFlags
87
    {
88
        NONE,
89
        RANGE,
90
        ADDRESS
91
    };
92
93
    struct ScRefFlagsAndType
94
    {
95
        ScRefFlags nResult;
96
        DetectFlags eDetected;
97
    };
98
99
    ScRefFlagsAndType lcl_ParseRangeOrAddress(ScRange& rScRange, ScAddress& rScAddress,
100
                                              const OUString& aAddress, const ScDocument& rDoc,
101
                                              SCCOL nCurCol, SCROW nCurRow)
102
0
    {
103
0
        ScRefFlagsAndType aRet;
104
105
        // Relative address parsing needs current position.
106
        // row,col parameters, not col,row!
107
0
        ScAddress::Details aDetails( rDoc.GetAddressConvention(), nCurRow, nCurCol);
108
109
        // start with the address convention set in the document
110
0
        aRet.nResult = rScRange.Parse(aAddress, rDoc, aDetails);
111
0
        if (aRet.nResult & ScRefFlags::VALID)
112
0
        {
113
0
            aRet.eDetected = DetectFlags::RANGE;
114
0
            return aRet;
115
0
        }
116
117
0
        aRet.nResult = rScAddress.Parse(aAddress, rDoc, aDetails);
118
0
        if (aRet.nResult & ScRefFlags::VALID)
119
0
        {
120
0
            aRet.eDetected = DetectFlags::ADDRESS;
121
0
            return aRet;
122
0
        }
123
124
        // try the default Calc (A1) address convention
125
0
        aRet.nResult = rScRange.Parse(aAddress, rDoc);
126
0
        if (aRet.nResult & ScRefFlags::VALID)
127
0
        {
128
0
            aRet.eDetected = DetectFlags::RANGE;
129
0
            return aRet;
130
0
        }
131
132
0
        aRet.nResult = rScAddress.Parse(aAddress, rDoc);
133
0
        if (aRet.nResult & ScRefFlags::VALID)
134
0
        {
135
0
            aRet.eDetected = DetectFlags::ADDRESS;
136
0
            return aRet;
137
0
        }
138
139
        // try the Excel A1 address convention
140
0
        aRet.nResult = rScRange.Parse(aAddress, rDoc, formula::FormulaGrammar::CONV_XL_A1);
141
0
        if (aRet.nResult & ScRefFlags::VALID)
142
0
        {
143
0
            aRet.eDetected = DetectFlags::RANGE;
144
0
            return aRet;
145
0
        }
146
147
        // try the Excel A1 address convention
148
0
        aRet.nResult = rScAddress.Parse(aAddress, rDoc, formula::FormulaGrammar::CONV_XL_A1);
149
0
        if (aRet.nResult & ScRefFlags::VALID)
150
0
        {
151
0
            aRet.eDetected = DetectFlags::ADDRESS;
152
0
            return aRet;
153
0
        }
154
155
        // try Excel R1C1 address convention
156
0
        aDetails.eConv = formula::FormulaGrammar::CONV_XL_R1C1;
157
0
        aRet.nResult = rScRange.Parse(aAddress, rDoc, aDetails);
158
0
        if (aRet.nResult & ScRefFlags::VALID)
159
0
        {
160
0
            aRet.eDetected = DetectFlags::RANGE;
161
0
            return aRet;
162
0
        }
163
164
0
        aRet.nResult = rScAddress.Parse(aAddress, rDoc, aDetails);
165
0
        if (aRet.nResult & ScRefFlags::VALID)
166
0
        {
167
0
            aRet.eDetected = DetectFlags::ADDRESS;
168
0
            return aRet;
169
0
        }
170
171
0
        aRet.nResult = ScRefFlags::ZERO;
172
0
        aRet.eDetected = DetectFlags::NONE;
173
174
0
        return aRet;
175
0
    }
176
}
177
178
void ScTabViewShell::ExecGoToTab( SfxRequest& rReq, SfxBindings& rBindings )
179
0
{
180
0
    SCTAB nTab;
181
0
    ScViewData& rViewData = GetViewData();
182
0
    ScDocument& rDoc = rViewData.GetDocument();
183
0
    SCTAB nTabCount = rDoc.GetTableCount();
184
0
    const SfxItemSet* pReqArgs = rReq.GetArgs();
185
0
    sal_uInt16 nSlot = rReq.GetSlot();
186
187
0
    if ( pReqArgs ) // command from Navigator with nTab
188
0
    {
189
        // sheet for basic is one-based
190
0
        nTab = static_cast<const SfxUInt16Item&>(pReqArgs->Get(nSlot)).GetValue() - 1;
191
0
        if ( nTab < nTabCount )
192
0
        {
193
0
            SetTabNo( nTab );
194
0
            rBindings.Update( nSlot );
195
196
0
            if( ! rReq.IsAPI() )
197
0
                rReq.Done();
198
0
        }
199
0
    }
200
0
    else            // command from Menu: ask for nTab
201
0
    {
202
0
        auto xRequest = std::make_shared<SfxRequest>(rReq);
203
0
        rReq.Ignore();
204
205
0
        ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
206
207
0
        VclPtr<AbstractScGoToTabDlg> pDlg(pFact->CreateScGoToTabDlg(GetFrameWeld()));
208
0
        pDlg->SetDescription(
209
0
            ScResId( STR_DLG_SELECTTABLE_TITLE ),
210
0
            ScResId( STR_DLG_SELECTTABLE_MASK ),
211
0
            ScResId( STR_DLG_SELECTTABLE_LBNAME ),
212
0
            GetStaticInterface()->GetSlot(SID_CURRENTTAB)->GetCommand(), HID_GOTOTABLEMASK, HID_GOTOTABLE );
213
214
        // fill all table names and select current tab
215
0
        OUString aTabName;
216
0
        for( nTab = 0; nTab < nTabCount; ++nTab )
217
0
        {
218
0
            if( rDoc.IsVisible( nTab ) )
219
0
            {
220
0
                rDoc.GetName( nTab, aTabName );
221
0
                pDlg->Insert( aTabName, rViewData.CurrentTabForData() == nTab );
222
0
            }
223
0
        }
224
225
0
        pDlg->StartExecuteAsync([this, nTab, nTabCount, pDlg,
226
0
                                 xRequest=std::move(xRequest)](sal_Int32 response) {
227
0
            if( response == RET_OK )
228
0
            {
229
0
                auto nTab2 = nTab;
230
0
                if( !GetViewData().GetDocument().GetTable( pDlg->GetSelectedEntry(), nTab2 ) )
231
0
                    nTab2 = nTabCount;
232
0
                if ( nTab2 < nTabCount )
233
0
                {
234
0
                    SetTabNo( nTab2 );
235
236
0
                    if ( !xRequest->IsAPI() )
237
0
                        xRequest->Done();
238
0
                }
239
0
            }
240
0
            else
241
0
            {
242
0
                xRequest->Ignore();
243
0
            }
244
0
            pDlg->disposeOnce();
245
0
        });
246
0
    }
247
0
}
248
249
void ScTabViewShell::FinishProtectTable()
250
0
{
251
0
    TabChanged();
252
0
    UpdateInputHandler(true);   // to immediately enable input again
253
0
    SelectionChanged();
254
0
}
255
256
void ScTabViewShell::ExecProtectTable( SfxRequest& rReq )
257
0
{
258
0
    ScModule* pScMod = ScModule::get();
259
0
    const SfxItemSet*   pReqArgs    = rReq.GetArgs();
260
0
    ScDocument&         rDoc = GetViewData().GetDocument();
261
0
    SCTAB               nTab = GetViewData().GetTabNumber();
262
0
    bool                bOldProtection = rDoc.IsTabProtected(nTab);
263
264
0
    if( pReqArgs )
265
0
    {
266
0
        const SfxPoolItem* pItem;
267
0
        bool bNewProtection = !bOldProtection;
268
0
        if( pReqArgs->HasItem( FID_PROTECT_TABLE, &pItem ) )
269
0
            bNewProtection = static_cast<const SfxBoolItem*>(pItem)->GetValue();
270
0
        if( bNewProtection == bOldProtection )
271
0
        {
272
0
            rReq.Ignore();
273
0
            return;
274
0
        }
275
0
    }
276
277
0
    if (bOldProtection)
278
0
    {
279
        // Unprotect a protected sheet.
280
281
0
        const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
282
0
        if (pProtect && pProtect->isProtectedWithPass())
283
0
        {
284
0
            std::shared_ptr<SfxRequest> xRequest;
285
0
            if (!pReqArgs)
286
0
            {
287
0
                xRequest = std::make_shared<SfxRequest>(rReq);
288
0
                rReq.Ignore(); // the 'old' request is not relevant any more
289
0
            }
290
291
0
            OUString aText( ScResId(SCSTR_PASSWORDOPT) );
292
0
            auto pDlg = std::make_shared<SfxPasswordDialog>(GetFrameWeld(), &aText);
293
0
            pDlg->set_title(ScResId(SCSTR_UNPROTECTTAB));
294
0
            pDlg->SetMinLen(0);
295
0
            pDlg->set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_TABLE)->GetCommand());
296
0
            pDlg->SetEditHelpId(HID_PASSWD_TABLE);
297
298
0
            pDlg->PreRun();
299
300
0
            weld::DialogController::runAsync(pDlg, [this, nTab, pDlg,
301
0
                                                    xRequest=std::move(xRequest)](sal_Int32 response) {
302
0
                if (response == RET_OK)
303
0
                {
304
0
                    OUString aPassword = pDlg->GetPassword();
305
0
                    Unprotect(nTab, aPassword);
306
0
                }
307
0
                if (xRequest)
308
0
                {
309
0
                    xRequest->AppendItem( SfxBoolItem(FID_PROTECT_TABLE, false) );
310
0
                    xRequest->Done();
311
0
                }
312
0
                FinishProtectTable();
313
0
            });
314
0
            return;
315
0
        }
316
0
        else
317
            // this sheet is not password-protected.
318
0
            Unprotect(nTab, std::u16string_view());
319
320
0
        if (!pReqArgs)
321
0
        {
322
0
            rReq.AppendItem( SfxBoolItem(FID_PROTECT_TABLE, false) );
323
0
            rReq.Done();
324
0
        }
325
0
    }
326
0
    else
327
0
    {
328
        // Protect a current sheet.
329
0
        std::shared_ptr<SfxRequest> xRequest;
330
0
        if (!pReqArgs)
331
0
        {
332
0
            xRequest = std::make_shared<SfxRequest>(rReq);
333
0
            rReq.Ignore(); // the 'old' request is not relevant any more
334
0
        }
335
336
0
        auto pDlg = std::make_shared<ScTableProtectionDlg>(GetFrameWeld());
337
338
0
        const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
339
0
        if (pProtect)
340
0
            pDlg->SetDialogData(*pProtect);
341
0
        weld::DialogController::runAsync(pDlg, [this, pDlg, pScMod, nTab,
342
0
                                               xRequest=std::move(xRequest)](sal_uInt32 nResult) {
343
0
            if (nResult == RET_OK)
344
0
            {
345
0
                pScMod->InputEnterHandler();
346
347
0
                ScTableProtection aNewProtect;
348
0
                pDlg->WriteData(aNewProtect);
349
0
                ProtectSheet(nTab, aNewProtect);
350
0
                if (xRequest)
351
0
                {
352
0
                    xRequest->AppendItem( SfxBoolItem(FID_PROTECT_TABLE, true) );
353
0
                    xRequest->Done();
354
0
                }
355
0
            }
356
0
            FinishProtectTable();
357
0
        });
358
0
        return;
359
0
    }
360
0
    FinishProtectTable();
361
0
}
362
363
void ScTabViewShell::Execute( SfxRequest& rReq )
364
0
{
365
0
    SfxViewFrame&       rThisFrame  = GetViewFrame();
366
0
    SfxBindings&        rBindings   = rThisFrame.GetBindings();
367
0
    ScModule* pScMod = ScModule::get();
368
0
    const SfxItemSet*   pReqArgs    = rReq.GetArgs();
369
0
    sal_uInt16              nSlot       = rReq.GetSlot();
370
371
0
    if (nSlot != SID_CURRENTCELL)       // comes with MouseButtonUp
372
0
        HideListBox();                  // Autofilter-DropDown-Listbox
373
374
0
    switch ( nSlot )
375
0
    {
376
0
        case FID_INSERT_FILE:
377
0
            {
378
0
                const SfxPoolItem* pItem;
379
0
                if ( pReqArgs &&
380
0
                     pReqArgs->GetItemState(FID_INSERT_FILE,true,&pItem) == SfxItemState::SET )
381
0
                {
382
0
                    OUString aFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
383
384
                        // insert position
385
386
0
                    Point aInsertPos;
387
0
                    if ( pReqArgs->GetItemState(FN_PARAM_1,true,&pItem) == SfxItemState::SET )
388
0
                        aInsertPos = static_cast<const SfxPointItem*>(pItem)->GetValue();
389
0
                    else
390
0
                        aInsertPos = GetInsertPos();
391
392
                        // as Link?
393
394
0
                    bool bAsLink = false;
395
0
                    if ( pReqArgs->GetItemState(FN_PARAM_2,true,&pItem) == SfxItemState::SET )
396
0
                        bAsLink = static_cast<const SfxBoolItem*>(pItem)->GetValue();
397
398
                        // execute
399
400
0
                    PasteFile( aInsertPos, aFileName, bAsLink );
401
0
                }
402
0
            }
403
0
            break;
404
405
0
        case SID_OPENDLG_EDIT_PRINTAREA:
406
0
            {
407
0
                sal_uInt16          nId  = ScPrintAreasDlgWrapper::GetChildWindowId();
408
0
                SfxChildWindow* pWnd = rThisFrame.GetChildWindow( nId );
409
410
0
                pScMod->SetRefDialog( nId, pWnd == nullptr );
411
0
            }
412
0
            break;
413
414
0
        case SID_CHANGE_PRINTAREA:
415
0
            {
416
0
                if ( pReqArgs )         // OK from dialog
417
0
                {
418
0
                    OUString aPrintStr;
419
0
                    OUString aRowStr;
420
0
                    OUString aColStr;
421
0
                    bool bEntire = false;
422
0
                    const SfxPoolItem* pItem;
423
0
                    if ( pReqArgs->GetItemState( SID_CHANGE_PRINTAREA, true, &pItem ) == SfxItemState::SET )
424
0
                        aPrintStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
425
0
                    if ( pReqArgs->GetItemState( FN_PARAM_2, true, &pItem ) == SfxItemState::SET )
426
0
                        aRowStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
427
0
                    if ( pReqArgs->GetItemState( FN_PARAM_3, true, &pItem ) == SfxItemState::SET )
428
0
                        aColStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
429
0
                    if ( pReqArgs->GetItemState( FN_PARAM_4, true, &pItem ) == SfxItemState::SET )
430
0
                        bEntire = static_cast<const SfxBoolItem*>(pItem)->GetValue();
431
432
0
                    SetPrintRanges( bEntire, &aPrintStr, &aColStr, &aRowStr, false );
433
434
0
                    rReq.Done();
435
0
                }
436
0
            }
437
0
            break;
438
439
0
        case SID_ADD_PRINTAREA:
440
0
        case SID_DEFINE_PRINTAREA:      // menu or basic
441
0
            {
442
0
                bool bAdd = ( nSlot == SID_ADD_PRINTAREA );
443
0
                if ( pReqArgs )
444
0
                {
445
0
                    OUString aPrintStr;
446
0
                    const SfxPoolItem* pItem;
447
0
                    if ( pReqArgs->GetItemState( SID_DEFINE_PRINTAREA, true, &pItem ) == SfxItemState::SET )
448
0
                        aPrintStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
449
0
                    SetPrintRanges( false, &aPrintStr, nullptr, nullptr, bAdd );
450
0
                }
451
0
                else
452
0
                {
453
0
                    SetPrintRanges( false, nullptr, nullptr, nullptr, bAdd );      // from selection
454
0
                    rReq.Done();
455
0
                }
456
0
            }
457
0
            break;
458
459
0
        case SID_DELETE_PRINTAREA:
460
0
            {
461
                // Clear currently defined print range if any, and reset it to
462
                // print entire sheet which is the default.
463
0
                OUString aEmpty;
464
0
                SetPrintRanges(true, &aEmpty, nullptr, nullptr, false);
465
0
                rReq.Done();
466
0
            }
467
0
            break;
468
469
0
        case FID_DEL_MANUALBREAKS:
470
0
            RemoveManualBreaks();
471
0
            rReq.Done();
472
0
            break;
473
474
0
        case FID_ADJUST_PRINTZOOM:
475
0
            AdjustPrintZoom();
476
0
            rReq.Done();
477
0
            break;
478
479
0
        case FID_RESET_PRINTZOOM:
480
0
            SetPrintZoom( 100 );     // 100%, not on pages
481
0
            rReq.Done();
482
0
            break;
483
484
0
        case SID_FORMATPAGE:
485
0
        case SID_STATUS_PAGESTYLE:
486
0
        case SID_HFEDIT:
487
0
            GetViewData().GetDocShell()->
488
0
                ExecutePageStyle( *this, rReq, GetViewData().CurrentTabForData() );
489
0
            break;
490
491
0
        case SID_JUMPTOMARK:
492
0
        case SID_CURRENTCELL:
493
0
            if ( pReqArgs )
494
0
            {
495
0
                OUString aAddress;
496
0
                const SfxPoolItem* pItem;
497
0
                if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
498
0
                    aAddress = static_cast<const SfxStringItem*>(pItem)->GetValue();
499
0
                else if ( nSlot == SID_JUMPTOMARK && pReqArgs->GetItemState(
500
0
                                            SID_JUMPTOMARK, true, &pItem ) == SfxItemState::SET )
501
0
                    aAddress = static_cast<const SfxStringItem*>(pItem)->GetValue();
502
503
                //  #i14927# SID_CURRENTCELL with a single cell must unmark if FN_PARAM_1
504
                //  isn't set (for recorded macros, because IsAPI is no longer available).
505
                //  ScGridWindow::MouseButtonUp no longer executes the slot for a single
506
                //  cell if there is a multi selection.
507
0
                bool bUnmark = ( nSlot == SID_CURRENTCELL );
508
0
                if ( pReqArgs->GetItemState( FN_PARAM_1, true, &pItem ) == SfxItemState::SET )
509
0
                    bUnmark = static_cast<const SfxBoolItem*>(pItem)->GetValue();
510
511
0
                bool bAlignToCursor = true;
512
0
                if (pReqArgs->GetItemState(FN_PARAM_2, true, &pItem) == SfxItemState::SET)
513
0
                    bAlignToCursor = static_cast<const SfxBoolItem*>(pItem)->GetValue();
514
515
0
                bool bForceGlobalName = false;
516
0
                if (pReqArgs->GetItemState(FN_PARAM_3, true, &pItem) == SfxItemState::SET)
517
0
                    bForceGlobalName = static_cast<const SfxBoolItem*>(pItem)->GetValue();
518
519
0
                if ( nSlot == SID_JUMPTOMARK )
520
0
                {
521
                    //  URL has to be decoded for escaped characters (%20)
522
0
                    aAddress = INetURLObject::decode( aAddress,
523
0
                                               INetURLObject::DecodeMechanism::WithCharset );
524
0
                }
525
526
0
                bool bFound = false;
527
0
                ScViewData& rViewData = GetViewData();
528
0
                ScDocument& rDoc      = rViewData.GetDocument();
529
0
                ScMarkData& rMark     = rViewData.GetMarkData();
530
0
                ScRange     aScRange;
531
0
                ScAddress   aScAddress;
532
0
                ScRefFlagsAndType aResult = lcl_ParseRangeOrAddress(aScRange, aScAddress, aAddress, rDoc,
533
0
                        rViewData.GetCurX(), rViewData.GetCurY());
534
0
                ScRefFlags  nResult = aResult.nResult;
535
0
                SCTAB       nTab = rViewData.CurrentTabForData();
536
0
                bool        bMark = true;
537
538
                // Is this a range ?
539
0
                if (aResult.eDetected == DetectFlags::RANGE)
540
0
                {
541
0
                    if ( nResult & ScRefFlags::TAB_3D )
542
0
                    {
543
0
                        if( aScRange.aStart.Tab() != nTab )
544
0
                        {
545
0
                            nTab = aScRange.aStart.Tab();
546
0
                            SetTabNo( nTab );
547
0
                        }
548
0
                    }
549
0
                    else
550
0
                    {
551
0
                        aScRange.aStart.SetTab( nTab );
552
0
                        aScRange.aEnd.SetTab( nTab );
553
0
                    }
554
0
                }
555
                // Is this a cell ?
556
0
                else if (aResult.eDetected == DetectFlags::ADDRESS)
557
0
                {
558
0
                    if ( nResult & ScRefFlags::TAB_3D )
559
0
                    {
560
0
                        if( aScAddress.Tab() != nTab )
561
0
                        {
562
0
                            nTab = aScAddress.Tab();
563
0
                            SetTabNo( nTab );
564
0
                        }
565
0
                    }
566
0
                    else
567
0
                        aScAddress.SetTab( nTab );
568
569
0
                    aScRange = ScRange( aScAddress, aScAddress );
570
                    // cells should not be marked
571
0
                    bMark = false;
572
0
                }
573
                // Is it a named area (first named ranges then database ranges)?
574
0
                else
575
0
                {
576
0
                    const RutlNameScope eScope = (bForceGlobalName ? RUTL_NAMES_GLOBAL : RUTL_NAMES);
577
0
                    ScAddress::Details aDetails( rDoc.GetAddressConvention(), rViewData.GetCurY(), rViewData.GetCurX());
578
0
                    if (ScRangeUtil::MakeRangeFromName( aAddress, rDoc, nTab, aScRange, eScope, aDetails, true) ||
579
0
                        ScRangeUtil::MakeRangeFromName( aAddress, rDoc, nTab, aScRange, RUTL_DBASE, aDetails, true))
580
0
                    {
581
0
                        nResult |= ScRefFlags::VALID;
582
0
                        if( aScRange.aStart.Tab() != nTab )
583
0
                        {
584
0
                            nTab = aScRange.aStart.Tab();
585
0
                            SetTabNo( nTab );
586
0
                        }
587
0
                    }
588
0
                }
589
590
0
                if ( !(nResult & ScRefFlags::VALID) && comphelper::string::isdigitAsciiString(aAddress) )
591
0
                {
592
0
                    sal_Int32 nNumeric = aAddress.toInt32();
593
0
                    if ( nNumeric > 0 && nNumeric <= rDoc.MaxRow()+1 )
594
0
                    {
595
                        // one-based row numbers
596
597
0
                        aScAddress.SetRow( static_cast<SCROW>(nNumeric - 1) );
598
0
                        aScAddress.SetCol( rViewData.GetCurX() );
599
0
                        aScAddress.SetTab( nTab );
600
0
                        aScRange = ScRange( aScAddress, aScAddress );
601
0
                        bMark    = false;
602
0
                        nResult  = ScRefFlags::VALID;
603
0
                    }
604
0
                }
605
606
0
                if ( !rDoc.ValidRow(aScRange.aStart.Row()) || !rDoc.ValidRow(aScRange.aEnd.Row()) )
607
0
                    nResult = ScRefFlags::ZERO;
608
609
                // we have found something
610
0
                if( nResult & ScRefFlags::VALID )
611
0
                {
612
0
                    bFound = true;
613
0
                    SCCOL nCol = aScRange.aStart.Col();
614
0
                    SCROW nRow = aScRange.aStart.Row();
615
0
                    bool bNothing = ( rViewData.GetCurX()==nCol && rViewData.GetCurY()==nRow );
616
617
                    // mark
618
0
                    if( bMark )
619
0
                    {
620
0
                        if (rMark.IsMarked())           // is the same range already marked?
621
0
                        {
622
0
                            ScRange aOldMark = rMark.GetMarkArea();
623
0
                            aOldMark.PutInOrder();
624
0
                            ScRange aCurrent = aScRange;
625
0
                            aCurrent.PutInOrder();
626
0
                            bNothing = ( aCurrent == aOldMark );
627
0
                        }
628
0
                        else
629
0
                            bNothing = false;
630
631
0
                        if (!bNothing)
632
0
                            MarkRange( aScRange, false );   // cursor comes after...
633
0
                    }
634
0
                    else
635
0
                    {
636
                        //  remove old selection, unless bUnmark argument is sal_False (from navigator)
637
0
                        if( bUnmark )
638
0
                        {
639
0
                            MoveCursorAbs( nCol, nRow,
640
0
                                SC_FOLLOW_NONE, false, false );
641
0
                        }
642
0
                    }
643
644
                    // and set cursor
645
646
                    // consider merged cells:
647
0
                    rDoc.SkipOverlapped(nCol, nRow, nTab);
648
649
                    // navigator calls are not part of the API!!!
650
651
0
                    if( bNothing )
652
0
                    {
653
0
                        if (rReq.IsAPI())
654
0
                            rReq.Ignore();      // if macro, then nothing
655
0
                        else
656
0
                            rReq.Done();        // then at least paint it
657
0
                    }
658
0
                    else
659
0
                    {
660
0
                        rViewData.ResetOldCursor();
661
0
                        SetCursor( nCol, nRow );
662
0
                        rBindings.Invalidate( SID_CURRENTCELL );
663
0
                        rBindings.Update( nSlot );
664
665
0
                        if (!rReq.IsAPI())
666
0
                            rReq.Done();
667
0
                    }
668
669
0
                    if (bAlignToCursor)
670
0
                    {
671
                        // align to cursor even if the cursor position hasn't changed,
672
                        // because the cursor may be set outside the visible area.
673
0
                        AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP );
674
0
                        if ( nSlot == SID_JUMPTOMARK && comphelper::LibreOfficeKit::isActive() )
675
0
                            rViewData.GetActiveWin()->notifyKitCellFollowJump();
676
0
                    }
677
678
0
                    rReq.SetReturnValue( SfxStringItem( SID_CURRENTCELL, aAddress ) );
679
0
                }
680
681
0
                if (!bFound)    // no valid range
682
0
                {
683
                    // if it is a sheet name, then switch (for Navigator/URL)
684
685
0
                    SCTAB nNameTab;
686
0
                    if ( rDoc.GetTable( aAddress, nNameTab ) )
687
0
                    {
688
0
                        bFound = true;
689
0
                        if (nNameTab != nTab)
690
0
                        {
691
0
                            if (!rDoc.IsVisible(nNameTab))
692
0
                                ErrorMessage(STR_ERR_HIDDEN_SHEET);
693
0
                            else
694
0
                                SetTabNo(nNameTab);
695
0
                        }
696
0
                    }
697
0
                }
698
699
0
                if ( !bFound && nSlot == SID_JUMPTOMARK )
700
0
                {
701
                    // test graphics objects (only for URL)
702
703
0
                    bFound = SelectObject( aAddress );
704
0
                }
705
706
0
                if (!bFound && !rReq.IsAPI())
707
0
                    ErrorMessage( STR_ERR_INVALID_AREA );
708
0
            }
709
0
            break;
710
711
0
        case SID_CURRENTOBJECT:
712
0
            if ( pReqArgs )
713
0
            {
714
0
                OUString aName = static_cast<const SfxStringItem&>(pReqArgs->Get(nSlot)).GetValue();
715
0
                SelectObject( aName );
716
0
            }
717
0
            break;
718
719
0
        case SID_CURRENTTAB:
720
0
            {
721
0
                ExecGoToTab( rReq, rBindings );
722
                //! otherwise an error ?
723
0
            }
724
0
            break;
725
726
0
        case SID_CURRENTDOC:
727
0
            if ( pReqArgs )
728
0
            {
729
0
                OUString aStrDocName( static_cast<const SfxStringItem&>(pReqArgs->
730
0
                                        Get(nSlot)).GetValue() );
731
732
0
                SfxViewFrame*   pViewFrame = nullptr;
733
0
                ScDocShell*     pDocSh = static_cast<ScDocShell*>(SfxObjectShell::GetFirst());
734
0
                bool            bFound = false;
735
736
                // search for ViewFrame to be activated
737
738
0
                while ( pDocSh && !bFound )
739
0
                {
740
0
                    if ( pDocSh->GetTitle() == aStrDocName )
741
0
                    {
742
0
                        pViewFrame = SfxViewFrame::GetFirst( pDocSh );
743
0
                        bFound = ( nullptr != pViewFrame );
744
0
                    }
745
746
0
                    pDocSh = static_cast<ScDocShell*>(SfxObjectShell::GetNext( *pDocSh ));
747
0
                }
748
749
0
                if ( bFound )
750
0
                    pViewFrame->GetFrame().Appear();
751
752
0
                rReq.Ignore();//XXX is handled by SFX
753
0
            }
754
0
            break;
755
756
0
        case SID_PRINTPREVIEW:
757
0
            {
758
0
                if ( !rThisFrame.GetFrame().IsInPlace() )          // not for OLE
759
0
                {
760
                    //  print preview is now always in the same frame as the tab view
761
                    //  -> always switch this frame back to normal view
762
                    //  (ScPreviewShell ctor reads view data)
763
764
                    // #102785#; finish input
765
0
                    pScMod->InputEnterHandler();
766
767
0
                    rThisFrame.GetDispatcher()->Execute( SID_VIEWSHELL1, SfxCallMode::ASYNCHRON );
768
0
                }
769
                //  else error (e.g. Ole)
770
0
            }
771
0
            break;
772
773
0
        case SID_DETECTIVE_DEL_ALL:
774
0
            DetectiveDelAll();
775
0
            rReq.Done();
776
0
            break;
777
778
        // SID_TABLE_ACTIVATE and SID_MARKAREA are called by basic for the
779
        // hidden View, to mark/switch on the visible View:
780
781
0
        case SID_TABLE_ACTIVATE:
782
0
            OSL_FAIL("old slot SID_TABLE_ACTIVATE");
783
0
            break;
784
785
0
        case SID_REPAINT:
786
0
            PaintGrid();
787
0
            PaintTop();
788
0
            PaintLeft();
789
0
            PaintExtras();
790
0
            rReq.Done();
791
0
            break;
792
793
0
        case FID_NORMALVIEWMODE:
794
0
        case FID_PAGEBREAKMODE:
795
0
            {
796
0
                bool bWantPageBreak = nSlot == FID_PAGEBREAKMODE;
797
798
                // check whether there is an explicit argument, use it
799
0
                const SfxPoolItem* pItem;
800
0
                if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
801
0
                {
802
0
                    bool bItemValue = static_cast<const SfxBoolItem*>(pItem)->GetValue();
803
0
                    bWantPageBreak = (nSlot == FID_PAGEBREAKMODE) == bItemValue;
804
0
                }
805
806
0
                if( GetViewData().IsPagebreakMode() != bWantPageBreak )
807
0
                {
808
0
                    SetPagebreakMode( bWantPageBreak );
809
0
                    UpdatePageBreakData();
810
0
                    SetCurSubShell( GetCurObjectSelectionType(), true );
811
0
                    PaintGrid();
812
0
                    PaintTop();
813
0
                    PaintLeft();
814
0
                    rBindings.Invalidate( nSlot );
815
0
                    rReq.AppendItem( SfxBoolItem( nSlot, true ) );
816
0
                    rReq.Done();
817
0
                }
818
0
            }
819
0
            break;
820
821
0
        case FID_FUNCTION_BOX:
822
0
            {
823
                // First make sure that the sidebar is visible
824
0
                rThisFrame.ShowChildWindow(SID_SIDEBAR);
825
826
0
                ::sfx2::sidebar::Sidebar::ShowPanel(u"ScFunctionsPanel",
827
0
                                                    rThisFrame.GetFrame().GetFrameInterface(),
828
0
                                                    true);
829
0
                rReq.Done ();
830
0
            }
831
0
            break;
832
833
0
        case FID_TOGGLESYNTAX:
834
0
            {
835
0
                bool bSet = !GetViewData().IsSyntaxMode();
836
0
                const SfxPoolItem* pItem;
837
0
                if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
838
0
                    bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
839
0
                GetViewData().SetSyntaxMode( bSet );
840
0
                PaintGrid();
841
0
                rBindings.Invalidate( FID_TOGGLESYNTAX );
842
0
                rReq.AppendItem( SfxBoolItem( nSlot, bSet ) );
843
0
                rReq.Done();
844
0
            }
845
0
            break;
846
0
        case FID_HANDLEDUPLICATERECORDS:
847
0
            {
848
0
                using namespace com::sun::star;
849
0
                table::CellRangeAddress aCellRange;
850
0
                rtl::Reference<ScTableSheetObj> xActiveSheet;
851
0
                DuplicatesResponse aResponse;
852
0
                bool bHasData = true;
853
854
0
                if (pReqArgs)
855
0
                {
856
0
                    const SfxPoolItem* pItem;
857
858
0
                    if (pReqArgs->HasItem(FID_HANDLEDUPLICATERECORDS, &pItem))
859
0
                        aResponse.bRemove = static_cast<const SfxBoolItem*>(pItem)->GetValue();
860
0
                    if (pReqArgs->HasItem(FN_PARAM_1, &pItem))
861
0
                        aResponse.bIncludesHeaders = static_cast<const SfxBoolItem*>(pItem)->GetValue();
862
0
                    if (pReqArgs->HasItem(FN_PARAM_2, &pItem))
863
0
                        aResponse.bDuplicateRows = static_cast<const SfxBoolItem*>(pItem)->GetValue();
864
0
                    if (pReqArgs->HasItem(FN_PARAM_3, &pItem))
865
0
                        aCellRange.StartColumn = static_cast<const SfxInt32Item*>(pItem)->GetValue();
866
0
                    if (pReqArgs->HasItem(FN_PARAM_4, &pItem))
867
0
                        aCellRange.StartRow = static_cast<const SfxInt32Item*>(pItem)->GetValue();
868
0
                    if (pReqArgs->HasItem(FN_PARAM_5, &pItem))
869
0
                        aCellRange.EndColumn = static_cast<const SfxInt32Item*>(pItem)->GetValue();
870
0
                    if (pReqArgs->HasItem(FN_PARAM_6, &pItem))
871
0
                        aCellRange.EndRow = static_cast<const SfxInt32Item*>(pItem)->GetValue();
872
0
                    if (pReqArgs->HasItem(FN_PARAM_7, &pItem))
873
0
                        aCellRange.Sheet = static_cast<const SfxInt32Item*>(pItem)->GetValue();
874
875
                    // check for the tab range here
876
0
                    if (aCellRange.StartColumn < 0 || aCellRange.StartRow < 0
877
0
                        || aCellRange.EndColumn < 0 || aCellRange.EndRow < 0
878
0
                        || aCellRange.StartRow > aCellRange.EndRow
879
0
                        || aCellRange.StartColumn > aCellRange.EndColumn || aCellRange.Sheet < 0
880
0
                        || aCellRange.Sheet >= GetViewData().GetDocument().GetTableCount())
881
0
                    {
882
0
                        rReq.Done();
883
0
                        break;
884
0
                    }
885
0
                    xActiveSheet = GetViewData().GetViewShell()->GetRangeWithSheet(aCellRange,
886
0
                                                                                   bHasData, true);
887
0
                    if (!bHasData)
888
0
                    {
889
0
                        rReq.Done();
890
0
                        break;
891
0
                    }
892
0
                    int nLenEntries
893
0
                        = (aResponse.bDuplicateRows ? aCellRange.EndColumn - aCellRange.StartColumn
894
0
                                                   : aCellRange.EndRow - aCellRange.StartRow);
895
0
                    for (int i = 0; i <= nLenEntries; ++i)
896
0
                        aResponse.vEntries.push_back(i);
897
0
                }
898
0
                else
899
0
                {
900
0
                    xActiveSheet = GetViewData().GetViewShell()->GetRangeWithSheet(aCellRange,
901
0
                                                                                   bHasData, false);
902
0
                    if (bHasData)
903
0
                    {
904
0
                        if (!GetViewData().GetMarkData().IsMarked())
905
0
                            GetViewData().GetViewShell()->ExtendSingleSelection(aCellRange);
906
907
0
                        uno::Reference<frame::XModel> xModel(GetViewData().GetDocShell()->GetModel());
908
0
                        uno::Reference<sheet::XSheetCellRange> xSheetRange(
909
0
                                xActiveSheet->getCellRangeByPosition(
910
0
                                    aCellRange.StartColumn, aCellRange.StartRow, aCellRange.EndColumn,
911
0
                                    aCellRange.EndRow),
912
0
                                uno::UNO_QUERY);
913
914
0
                        ScRange aRange(ScAddress(aCellRange.StartColumn, aCellRange.StartRow,
915
0
                                    GetViewData().CurrentTabForData()),
916
0
                                ScAddress(aCellRange.EndColumn, aCellRange.EndRow,
917
0
                                    GetViewData().CurrentTabForData()));
918
919
0
                        uno::Reference<sheet::XCellRangeData> xCellRangeData(xSheetRange,
920
0
                                uno::UNO_QUERY);
921
0
                        uno::Sequence<uno::Sequence<uno::Any>> aDataArray
922
0
                            = xCellRangeData->getDataArray();
923
924
0
                        ScDuplicateRecordsDlg aDlg(GetFrameWeld(), aDataArray, GetViewData(), aRange);
925
926
0
                        bHasData = aDlg.run();
927
0
                        if (bHasData)
928
0
                            aResponse = aDlg.GetDialogData();
929
0
                        else
930
0
                        {
931
0
                            rReq.Done();
932
0
                            break;
933
0
                        }
934
0
                    }
935
0
                    else
936
0
                    {
937
0
                        std::unique_ptr<weld::MessageDialog> aDialog(
938
0
                            Application::CreateMessageDialog(GetFrameWeld(),
939
0
                                                             VclMessageType::Warning,
940
0
                                                             VclButtonsType::Ok,
941
0
                                                             ScResId(STR_DUPLICATERECORDSDLG_NODATAFOUND)));
942
0
                        aDialog->set_title(ScResId(STR_DUPLICATERECORDSDLG_WARNING));
943
0
                        aDialog->run();
944
0
                    }
945
0
                }
946
947
0
                if (bHasData)
948
0
                {
949
0
                    if (aResponse.bRemove)
950
0
                        GetViewData().GetViewShell()->HandleDuplicateRecordsRemove(
951
0
                                xActiveSheet, aCellRange, aResponse.bIncludesHeaders,
952
0
                                aResponse.bDuplicateRows, aResponse.vEntries);
953
0
                    else
954
0
                        GetViewData().GetViewShell()->HandleDuplicateRecordsHighlight(
955
0
                                xActiveSheet, aCellRange, aResponse.bIncludesHeaders,
956
0
                                aResponse.bDuplicateRows, aResponse.vEntries);
957
0
                }
958
959
0
                rReq.Done();
960
0
            }
961
0
            break;
962
0
        case FID_TOGGLECOLROWHIGHLIGHTING:
963
0
            {
964
0
                bool bNewVal = !officecfg::Office::Calc::Content::Display::ColumnRowHighlighting::get();
965
966
0
                auto pChange(comphelper::ConfigurationChanges::create());
967
0
                officecfg::Office::Calc::Content::Display::ColumnRowHighlighting::set(bNewVal, pChange);
968
0
                pChange->commit();
969
970
0
                rReq.AppendItem(SfxBoolItem(nSlot, bNewVal));
971
0
                rReq.Done();
972
0
            }
973
0
            break;
974
0
        case FID_TOGGLEHEADERS:
975
0
            {
976
0
                bool bSet = !GetViewData().IsHeaderMode();
977
0
                const SfxPoolItem* pItem;
978
0
                if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
979
0
                    bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
980
0
                GetViewData().SetHeaderMode( bSet );
981
0
                RepeatResize();
982
0
                rBindings.Invalidate( FID_TOGGLEHEADERS );
983
0
                rReq.AppendItem( SfxBoolItem( nSlot, bSet ) );
984
0
                rReq.Done();
985
0
            }
986
0
            break;
987
988
0
        case FID_TOGGLEFORMULA:
989
0
            {
990
0
                ScViewData& rViewData = GetViewData();
991
0
                const ScViewOptions& rOpts = rViewData.GetOptions();
992
0
                bool bFormulaMode = !rOpts.GetOption(sc::ViewOption::FORMULAS);
993
0
                const SfxPoolItem *pItem;
994
0
                if( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
995
0
                    bFormulaMode = static_cast<const SfxBoolItem *>(pItem)->GetValue();
996
997
0
                ScViewOptions aSetOpts = rOpts;
998
0
                aSetOpts.SetOption(sc::ViewOption::FORMULAS, bFormulaMode);
999
0
                rViewData.SetOptions( aSetOpts );
1000
0
                ScDocument& rDoc = rViewData.GetDocument();
1001
0
                rDoc.SetViewOptions(aSetOpts);
1002
1003
0
                rViewData.GetDocShell()->PostPaintGridAll();
1004
1005
0
                rBindings.Invalidate( FID_TOGGLEFORMULA );
1006
0
                rReq.AppendItem( SfxBoolItem( nSlot, bFormulaMode ) );
1007
0
                rReq.Done();
1008
0
            }
1009
0
            break;
1010
1011
0
        case FID_TOGGLEINPUTLINE:
1012
0
            {
1013
0
                sal_uInt16          nId  = ScInputWindowWrapper::GetChildWindowId();
1014
0
                SfxChildWindow* pWnd = rThisFrame.GetChildWindow( nId );
1015
0
                bool bSet = ( pWnd == nullptr );
1016
0
                const SfxPoolItem* pItem;
1017
0
                if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET )
1018
0
                    bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
1019
1020
0
                rThisFrame.SetChildWindow( nId, bSet );
1021
0
                rBindings.Invalidate( FID_TOGGLEINPUTLINE );
1022
0
                rReq.AppendItem( SfxBoolItem( nSlot, bSet ) );
1023
0
                rReq.Done();
1024
0
            }
1025
0
            break;
1026
1027
        // handling for SID_ZOOM_IN and SID_ZOOM_OUT is ScTabView::ScrollCommand
1028
        // CommandWheelMode::ZOOM inspired
1029
0
        case SID_ZOOM_IN:
1030
0
        case SID_ZOOM_OUT:
1031
0
            {
1032
0
                HideNoteOverlay();
1033
1034
0
                if (!GetViewData().GetViewShell()->GetViewFrame().GetFrame().IsInPlace())
1035
0
                {
1036
                    //  for ole inplace editing, the scale is defined by the visarea and client size
1037
                    //  and can't be changed directly
1038
1039
0
                    double fOldY = GetViewData().GetZoomY();
1040
0
                    sal_uInt16 nOld = tools::Long(fOldY * 100);
1041
0
                    sal_uInt16 nNew;
1042
0
                    if (SID_ZOOM_OUT == nSlot)
1043
0
                        nNew = std::max(MINZOOM, basegfx::zoomtools::zoomOut(nOld));
1044
0
                    else
1045
0
                        nNew = std::min(MAXZOOM, basegfx::zoomtools::zoomIn(nOld));
1046
0
                    if ( nNew != nOld)
1047
0
                    {
1048
0
                        bool bSyncZoom = pScMod->GetAppOptions().GetSynchronizeZoom();
1049
0
                        SetZoomType(SvxZoomType::PERCENT, bSyncZoom);
1050
0
                        double fFract = double(nNew) / 100;
1051
0
                        SetZoom(fFract, fFract, bSyncZoom);
1052
0
                        PaintGrid();
1053
0
                        PaintTop();
1054
0
                        PaintLeft();
1055
0
                        rBindings.Invalidate(SID_ATTR_ZOOM);
1056
0
                        rBindings.Invalidate(SID_ATTR_ZOOMSLIDER);
1057
0
                        rBindings.Invalidate(SID_ZOOM_IN);
1058
0
                        rBindings.Invalidate(SID_ZOOM_OUT);
1059
0
                        rReq.Done();
1060
0
                    }
1061
0
                }
1062
0
            }
1063
0
            break;
1064
1065
        // Handle sheet views
1066
0
        case FID_NEW_SHEET_VIEW:
1067
0
            MakeNewSheetView();
1068
0
        break;
1069
0
        case FID_REMOVE_SHEET_VIEW:
1070
0
            RemoveCurrentSheetView();
1071
0
        break;
1072
0
        case FID_EXIT_SHEET_VIEW:
1073
0
            ExitSheetView();
1074
0
        break;
1075
0
        case FID_SELECT_SHEET_VIEW:
1076
0
        {
1077
0
            const SfxPoolItem* pItem = nullptr;
1078
0
            if (pReqArgs != nullptr && pReqArgs->HasItem(FN_PARAM_1, &pItem))
1079
0
            {
1080
0
                const sal_Int32 nValue = static_cast<const SfxInt32Item*>(pItem)->GetValue();
1081
0
                sc::SheetViewID nID(nValue);
1082
0
                if (nID != sc::InvalidSheetViewID)
1083
0
                {
1084
0
                    SelectSheetView(nID);
1085
0
                }
1086
0
            }
1087
0
            else
1088
0
            {
1089
0
                ScViewData& rViewData = GetViewData();
1090
0
                auto pDialog = std::make_shared<sc::SelectSheetViewDialog>(GetFrameWeld(), rViewData);
1091
0
                weld::DialogController::runAsync(pDialog, [this, pDialog](sal_uInt32 nResult) {
1092
0
                    if (RET_OK != nResult)
1093
0
                        return;
1094
1095
0
                    sc::SheetViewID nID = pDialog->getSelectedSheetViewID();
1096
0
                    if (nID != sc::InvalidSheetViewID)
1097
0
                    {
1098
0
                        SelectSheetView(nID);
1099
0
                    }
1100
0
                });
1101
0
            }
1102
0
            rReq.Done();
1103
0
        }
1104
0
        break;
1105
1106
0
        case SID_ATTR_ZOOM: // status row
1107
0
        case FID_SCALE:
1108
0
            {
1109
0
                bool bSyncZoom = pScMod->GetAppOptions().GetSynchronizeZoom();
1110
0
                SvxZoomType eOldZoomType = GetZoomType();
1111
0
                SvxZoomType eNewZoomType = eOldZoomType;
1112
0
                double fOldY = GetViewData().GetZoomY();  // Y is shown
1113
0
                sal_uInt16 nOldZoom = static_cast<sal_uInt16>(tools::Long( fOldY * 100 ));
1114
0
                sal_uInt16 nZoom = nOldZoom;
1115
0
                bool bCancel = false;
1116
1117
0
                if ( pReqArgs )
1118
0
                {
1119
0
                    const SvxZoomItem& rZoomItem = pReqArgs->Get(SID_ATTR_ZOOM);
1120
1121
0
                    eNewZoomType = rZoomItem.GetType();
1122
0
                    nZoom     = rZoomItem.GetValue();
1123
0
                }
1124
0
                else
1125
0
                {
1126
0
                    SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<SID_ATTR_ZOOM, SID_ATTR_ZOOM>( GetPool() ));
1127
0
                    SvxZoomItem     aZoomItem( eOldZoomType, nOldZoom, SID_ATTR_ZOOM );
1128
0
                    ScopedVclPtr<AbstractSvxZoomDialog> pDlg;
1129
0
                    ScMarkData&     rMark = GetViewData().GetMarkData();
1130
0
                    SvxZoomEnableFlags nBtnFlags = SvxZoomEnableFlags::N50
1131
0
                                                | SvxZoomEnableFlags::N75
1132
0
                                                | SvxZoomEnableFlags::N100
1133
0
                                                | SvxZoomEnableFlags::N150
1134
0
                                                | SvxZoomEnableFlags::N200
1135
0
                                                | SvxZoomEnableFlags::WHOLEPAGE
1136
0
                                                | SvxZoomEnableFlags::PAGEWIDTH;
1137
1138
0
                    if ( rMark.IsMarked() || rMark.IsMultiMarked() )
1139
0
                        nBtnFlags = nBtnFlags | SvxZoomEnableFlags::OPTIMAL;
1140
1141
0
                    aZoomItem.SetValueSet( nBtnFlags );
1142
0
                    aSet.Put( aZoomItem );
1143
0
                    SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
1144
0
                    pDlg.disposeAndReset(pFact->CreateSvxZoomDialog(GetFrameWeld(), aSet));
1145
0
                    pDlg->SetLimits( MINZOOM, MAXZOOM );
1146
1147
0
                    bCancel = ( RET_CANCEL == pDlg->Execute() );
1148
1149
                    // bCancel is True only if we were in the previous if block,
1150
                    // so no need to check again pDlg
1151
0
                    if ( !bCancel )
1152
0
                    {
1153
0
                        const SvxZoomItem&  rZoomItem = pDlg->GetOutputItemSet()->
1154
0
                                                    Get( SID_ATTR_ZOOM );
1155
1156
0
                        eNewZoomType = rZoomItem.GetType();
1157
0
                        nZoom     = rZoomItem.GetValue();
1158
0
                    }
1159
0
                }
1160
1161
0
                if ( !bCancel )
1162
0
                {
1163
0
                    if ( eNewZoomType == SvxZoomType::PERCENT )
1164
0
                    {
1165
0
                        if ( nZoom < MINZOOM )  nZoom = MINZOOM;
1166
0
                        if ( nZoom > MAXZOOM )  nZoom = MAXZOOM;
1167
0
                    }
1168
0
                    else
1169
0
                    {
1170
0
                        nZoom = CalcZoom( eNewZoomType, nOldZoom );
1171
0
                        bCancel = nZoom == 0;
1172
0
                    }
1173
1174
0
                    switch ( eNewZoomType )
1175
0
                    {
1176
0
                        case SvxZoomType::WHOLEPAGE:
1177
0
                        case SvxZoomType::PAGEWIDTH:
1178
0
                            SetZoomType( eNewZoomType, bSyncZoom );
1179
0
                            break;
1180
1181
0
                        default:
1182
0
                            SetZoomType( SvxZoomType::PERCENT, bSyncZoom );
1183
0
                    }
1184
0
                }
1185
1186
0
                if ( nZoom != nOldZoom && !bCancel )
1187
0
                {
1188
0
                    if (!GetViewData().IsPagebreakMode())
1189
0
                    {
1190
0
                        ScAppOptions aNewOpt = pScMod->GetAppOptions();
1191
0
                        aNewOpt.SetZoom( nZoom );
1192
0
                        aNewOpt.SetZoomType( GetZoomType() );
1193
0
                        pScMod->SetAppOptions( aNewOpt );
1194
0
                    }
1195
0
                    double fFract = double(nZoom) / 100;
1196
0
                    SetZoom( fFract, fFract, bSyncZoom );
1197
0
                    PaintGrid();
1198
0
                    PaintTop();
1199
0
                    PaintLeft();
1200
0
                    rBindings.Invalidate( SID_ATTR_ZOOM );
1201
0
                    rReq.AppendItem( SvxZoomItem( GetZoomType(), nZoom, TypedWhichId<SvxZoomItem>(nSlot) ) );
1202
0
                    rReq.Done();
1203
0
                }
1204
0
            }
1205
0
            break;
1206
1207
0
        case SID_ATTR_ZOOMSLIDER:
1208
0
            {
1209
0
                const SfxPoolItem* pItem = nullptr;
1210
0
                bool bSyncZoom = pScMod->GetAppOptions().GetSynchronizeZoom();
1211
0
                if ( pReqArgs && pReqArgs->GetItemState(SID_ATTR_ZOOMSLIDER, true, &pItem) == SfxItemState::SET )
1212
0
                {
1213
0
                    const sal_uInt16 nCurrentZoom = static_cast<const SvxZoomSliderItem *>(pItem)->GetValue();
1214
0
                    if( nCurrentZoom )
1215
0
                    {
1216
0
                        SetZoomType( SvxZoomType::PERCENT, bSyncZoom );
1217
0
                        if (!GetViewData().IsPagebreakMode())
1218
0
                        {
1219
0
                            ScAppOptions aNewOpt = pScMod->GetAppOptions();
1220
0
                            aNewOpt.SetZoom( nCurrentZoom );
1221
0
                            collectUIInformation(OUString::number(nCurrentZoom));
1222
0
                            aNewOpt.SetZoomType( GetZoomType() );
1223
0
                            pScMod->SetAppOptions( aNewOpt );
1224
0
                        }
1225
0
                        double fFract = double(nCurrentZoom) / 100;
1226
0
                        SetZoom( fFract, fFract, bSyncZoom );
1227
0
                        PaintGrid();
1228
0
                        PaintTop();
1229
0
                        PaintLeft();
1230
0
                        rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
1231
0
                        rBindings.Invalidate( SID_ZOOM_IN );
1232
0
                        rBindings.Invalidate( SID_ZOOM_OUT );
1233
0
                        rReq.Done();
1234
0
                    }
1235
0
                }
1236
0
            }
1237
0
            break;
1238
1239
0
        case FID_TAB_SELECTALL:
1240
0
            SelectAllTables();
1241
0
            rReq.Done();
1242
0
            break;
1243
1244
0
        case FID_TAB_DESELECTALL:
1245
0
            DeselectAllTables();
1246
0
            rReq.Done();
1247
0
            break;
1248
1249
0
        case SID_SELECT_TABLES:
1250
0
        {
1251
0
            ScViewData& rViewData = GetViewData();
1252
0
            ScDocument& rDoc = rViewData.GetDocument();
1253
0
            ScMarkData& rMark = rViewData.GetMarkData();
1254
0
            SCTAB nTabCount = rDoc.GetTableCount();
1255
0
            SCTAB nTab;
1256
1257
0
            ::std::vector < sal_Int32 > aIndexList;
1258
0
            const SfxIntegerListItem* pItem = rReq.GetArg(SID_SELECT_TABLES);
1259
0
            if ( pItem )
1260
0
                aIndexList = pItem->GetList();
1261
0
            else
1262
0
            {
1263
0
                ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
1264
1265
0
                ScopedVclPtr<AbstractScShowTabDlg> pDlg(pFact->CreateScShowTabDlg(GetFrameWeld()));
1266
0
                pDlg->SetDescription(
1267
0
                    ScResId( STR_DLG_SELECTTABLES_TITLE ),
1268
0
                    ScResId( STR_DLG_SELECTTABLES_LBNAME ),
1269
0
                    GetStaticInterface()->GetSlot(SID_SELECT_TABLES)->GetCommand(), HID_SELECTTABLES );
1270
1271
                // fill all table names with selection state
1272
0
                OUString aTabName;
1273
0
                for( nTab = 0; nTab < nTabCount; ++nTab )
1274
0
                {
1275
0
                    rDoc.GetName( nTab, aTabName );
1276
0
                    pDlg->Insert( aTabName, rMark.GetTableSelect( nTab ) );
1277
0
                }
1278
1279
0
                if( pDlg->Execute() == RET_OK )
1280
0
                {
1281
0
                    aIndexList = pDlg->GetSelectedRows();
1282
0
                    pDlg.disposeAndClear();
1283
0
                    rReq.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES, std::vector(aIndexList) ) );
1284
0
                }
1285
0
                else
1286
0
                    rReq.Ignore();
1287
0
            }
1288
1289
0
            if ( !aIndexList.empty() )
1290
0
            {
1291
0
                sal_uInt16 nSelCount = aIndexList.size();
1292
0
                sal_uInt16 nSelIx;
1293
0
                SCTAB nFirstVisTab = 0;
1294
1295
                // special case: only hidden tables selected -> do nothing
1296
0
                bool bVisSelected = false;
1297
0
                for( nSelIx = 0; !bVisSelected && (nSelIx < nSelCount); ++nSelIx )
1298
0
                {
1299
0
                    nFirstVisTab = static_cast<SCTAB>(aIndexList[nSelIx]);
1300
0
                    bVisSelected = rDoc.IsVisible( nFirstVisTab );
1301
0
                }
1302
0
                if( !bVisSelected )
1303
0
                    nSelCount = 0;
1304
1305
                // select the tables
1306
0
                if( nSelCount )
1307
0
                {
1308
0
                    for( nTab = 0; nTab < nTabCount; ++nTab )
1309
0
                        rMark.SelectTable( nTab, false );
1310
1311
0
                    for( nSelIx = 0; nSelIx < nSelCount; ++nSelIx )
1312
0
                        rMark.SelectTable( static_cast<SCTAB>(aIndexList[nSelIx]), true );
1313
1314
                    // activate another table, if current is deselected
1315
0
                    if( !rMark.GetTableSelect( rViewData.CurrentTabForData() ) )
1316
0
                    {
1317
0
                        rMark.SelectTable( nFirstVisTab, true );
1318
0
                        SetTabNo( nFirstVisTab );
1319
0
                    }
1320
1321
0
                    rViewData.GetDocShell()->PostPaintExtras();
1322
0
                    SfxBindings& rBind = rViewData.GetBindings();
1323
0
                    rBind.Invalidate( FID_FILL_TAB );
1324
0
                    rBind.Invalidate( FID_TAB_DESELECTALL );
1325
0
                }
1326
1327
0
                rReq.Done();
1328
0
            }
1329
0
        }
1330
0
        break;
1331
1332
0
        case SID_OUTLINE_DELETEALL:
1333
0
            RemoveAllOutlines();
1334
0
            rReq.Done();
1335
0
            break;
1336
1337
0
        case SID_AUTO_OUTLINE:
1338
0
            AutoOutline();
1339
0
            rReq.Done();
1340
0
            break;
1341
1342
0
        case SID_WINDOW_SPLIT:
1343
0
            {
1344
0
                ScSplitMode eHSplit = GetViewData().GetHSplitMode();
1345
0
                ScSplitMode eVSplit = GetViewData().GetVSplitMode();
1346
0
                if ( eHSplit == SC_SPLIT_NORMAL || eVSplit == SC_SPLIT_NORMAL )     // remove
1347
0
                    RemoveSplit();
1348
0
                else if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX )      // normal
1349
0
                    FreezeSplitters( false );
1350
0
                else                                                                // create
1351
0
                    SplitAtCursor();
1352
0
                rReq.Done();
1353
1354
0
                InvalidateSplit();
1355
0
            }
1356
0
            break;
1357
1358
0
        case SID_WINDOW_FIX:
1359
0
            {
1360
0
                if (!comphelper::LibreOfficeKit::isActive())
1361
0
                {
1362
0
                    ScSplitMode eHSplit = GetViewData().GetHSplitMode();
1363
0
                    ScSplitMode eVSplit = GetViewData().GetVSplitMode();
1364
0
                    if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX )           // remove
1365
0
                        RemoveSplit();
1366
0
                    else
1367
0
                        FreezeSplitters( true, SC_SPLIT_METHOD_CURSOR);                 // create or fixate
1368
0
                    rReq.Done();
1369
0
                    InvalidateSplit();
1370
0
                }
1371
0
                else
1372
0
                {
1373
0
                    ScViewData& rViewData = GetViewData();
1374
0
                    SCTAB nThisTab = rViewData.GetTabNumber();
1375
0
                    bool bChangedX = false, bChangedY = false;
1376
0
                    if (rViewData.GetLOKSheetFreezeIndex(true) > 0 ||
1377
0
                        rViewData.GetLOKSheetFreezeIndex(false) > 0 )                             // remove freeze
1378
0
                    {
1379
0
                        bChangedX = rViewData.RemoveLOKFreeze();
1380
0
                    }                                                                            // create or fixate
1381
0
                    else
1382
0
                    {
1383
0
                        bChangedX = rViewData.SetLOKSheetFreezeIndex(rViewData.GetCurX(), true);    // Freeze column
1384
0
                        bChangedY = rViewData.SetLOKSheetFreezeIndex(rViewData.GetCurY(), false);   // Freeze row
1385
0
                    }
1386
1387
0
                    rReq.Done();
1388
0
                    if (bChangedX || bChangedY)
1389
0
                    {
1390
0
                        rBindings.Invalidate( SID_WINDOW_FIX );
1391
0
                        rBindings.Invalidate( SID_WINDOW_FIX_COL );
1392
0
                        rBindings.Invalidate( SID_WINDOW_FIX_ROW );
1393
                        // Invalidate the slot for all views on the same tab of the document.
1394
0
                        SfxLokHelper::forEachOtherView(this, [nThisTab](ScTabViewShell* pOther) {
1395
0
                            ScViewData& rOtherViewData = pOther->GetViewData();
1396
0
                            if (rOtherViewData.GetTabNumber() != nThisTab)
1397
0
                                return;
1398
1399
0
                            SfxBindings& rOtherBind = rOtherViewData.GetBindings();
1400
0
                            rOtherBind.Invalidate( SID_WINDOW_FIX );
1401
0
                            rOtherBind.Invalidate( SID_WINDOW_FIX_COL );
1402
0
                            rOtherBind.Invalidate( SID_WINDOW_FIX_ROW );
1403
0
                        });
1404
0
                        if (!GetViewData().GetDocShell()->IsReadOnly())
1405
0
                            GetViewData().GetDocShell()->SetDocumentModified();
1406
0
                    }
1407
0
                }
1408
0
            }
1409
0
            break;
1410
1411
0
        case SID_WINDOW_FIX_COL:
1412
0
        case SID_WINDOW_FIX_ROW:
1413
0
            {
1414
0
                bool bIsCol = (nSlot == SID_WINDOW_FIX_COL);
1415
0
                sal_Int32 nFreezeIndex = 1;
1416
0
                if (const SfxInt32Item* pItem = rReq.GetArg<SfxInt32Item>(FN_PARAM_1))
1417
0
                {
1418
0
                    nFreezeIndex = pItem->GetValue();
1419
0
                    if (nFreezeIndex < 0)
1420
0
                        nFreezeIndex = 0;
1421
0
                }
1422
1423
0
                if (comphelper::LibreOfficeKit::isActive())
1424
0
                {
1425
0
                    ScViewData& rViewData = GetViewData();
1426
0
                    SCTAB nThisTab = rViewData.GetTabNumber();
1427
0
                    bool bChanged = rViewData.SetLOKSheetFreezeIndex(nFreezeIndex, bIsCol);
1428
0
                    rReq.Done();
1429
0
                    if (bChanged)
1430
0
                    {
1431
0
                        rBindings.Invalidate( SID_WINDOW_FIX );
1432
0
                        rBindings.Invalidate(nSlot);
1433
                        // Invalidate the slot for all views on the same tab of the document.
1434
0
                        SfxLokHelper::forEachOtherView(this, [nSlot, nThisTab](ScTabViewShell* pOther) {
1435
0
                            ScViewData& rOtherViewData = pOther->GetViewData();
1436
0
                            if (rOtherViewData.GetTabNumber() != nThisTab)
1437
0
                                return;
1438
1439
0
                            SfxBindings& rOtherBind = rOtherViewData.GetBindings();
1440
0
                            rOtherBind.Invalidate( SID_WINDOW_FIX );
1441
0
                            rOtherBind.Invalidate(nSlot);
1442
0
                        });
1443
0
                        if (!GetViewData().GetDocShell()->IsReadOnly())
1444
0
                            GetViewData().GetDocShell()->SetDocumentModified();
1445
0
                    }
1446
0
                }
1447
0
                else
1448
0
                {
1449
0
                    FreezeSplitters( true, bIsCol ? SC_SPLIT_METHOD_COL : SC_SPLIT_METHOD_ROW, nFreezeIndex);
1450
0
                    rReq.Done();
1451
0
                    InvalidateSplit();
1452
0
                }
1453
0
            }
1454
0
            break;
1455
1456
0
        case FID_CHG_SHOW:
1457
0
            {
1458
0
                sal_uInt16          nId  = ScHighlightChgDlgWrapper::GetChildWindowId();
1459
0
                SfxChildWindow* pWnd = rThisFrame.GetChildWindow( nId );
1460
1461
0
                pScMod->SetRefDialog( nId, pWnd == nullptr );
1462
0
            }
1463
0
            break;
1464
1465
0
        case FID_CHG_ACCEPT:
1466
0
            {
1467
0
                rThisFrame.ToggleChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId());
1468
0
                GetViewFrame().GetBindings().Invalidate(FID_CHG_ACCEPT);
1469
0
                rReq.Done ();
1470
1471
                /*
1472
                sal_uInt16          nId  = ScAcceptChgDlgWrapper::GetChildWindowId();
1473
                SfxChildWindow* pWnd = rThisFrame.GetChildWindow( nId );
1474
1475
                pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
1476
                */
1477
0
            }
1478
0
            break;
1479
1480
0
        case FID_CHG_COMMENT:
1481
0
            {
1482
0
                ScViewData& rData = GetViewData();
1483
0
                ScAddress aCursorPos( rData.GetCurX(), rData.GetCurY(), rData.CurrentTabForData() );
1484
0
                ScDocShell* pDocSh = rData.GetDocShell();
1485
1486
0
                ScChangeAction* pAction = pDocSh->GetChangeAction( aCursorPos );
1487
0
                if ( pAction )
1488
0
                {
1489
0
                    const SfxPoolItem* pItem;
1490
0
                    if ( pReqArgs &&
1491
0
                         pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET &&
1492
0
                         dynamic_cast<const SfxStringItem*>( pItem) !=  nullptr )
1493
0
                    {
1494
0
                        OUString aComment = static_cast<const SfxStringItem*>(pItem)->GetValue();
1495
0
                        pDocSh->SetChangeComment( pAction, aComment );
1496
0
                        rReq.Done();
1497
0
                    }
1498
0
                    else
1499
0
                    {
1500
0
                        pDocSh->ExecuteChangeCommentDialog(pAction, GetFrameWeld());
1501
0
                        rReq.Done();
1502
0
                    }
1503
0
                }
1504
0
            }
1505
0
            break;
1506
1507
0
        case SID_CREATE_SW_DRAWVIEW:
1508
            //  is called by Forms, when the DrawView has to be created with all
1509
            //  the extras
1510
0
            if (!GetScDrawView())
1511
0
            {
1512
0
                GetViewData().GetDocShell()->MakeDrawLayer();
1513
0
                rBindings.InvalidateAll(false);
1514
0
            }
1515
0
            break;
1516
1517
0
        case FID_PROTECT_DOC:
1518
0
            {
1519
0
                ScDocument& rDoc = GetViewData().GetDocument();
1520
1521
0
                if( pReqArgs )
1522
0
                {
1523
0
                    const SfxPoolItem* pItem;
1524
0
                    if( pReqArgs->HasItem( FID_PROTECT_DOC, &pItem ) &&
1525
0
                        static_cast<const SfxBoolItem*>(pItem)->GetValue() == rDoc.IsDocProtected() )
1526
0
                    {
1527
0
                        rReq.Ignore();
1528
0
                        break;
1529
0
                    }
1530
0
                }
1531
1532
0
                ScDocProtection* pProtect = rDoc.GetDocProtection();
1533
0
                if (pProtect && pProtect->isProtected())
1534
0
                {
1535
0
                    bool bCancel = false;
1536
0
                    OUString aPassword;
1537
1538
0
                    if (pProtect->isProtectedWithPass())
1539
0
                    {
1540
0
                        OUString aText(ScResId(SCSTR_PASSWORD));
1541
1542
0
                        SfxPasswordDialog aDlg(GetFrameWeld(), &aText);
1543
0
                        aDlg.set_title(ScResId(SCSTR_UNPROTECTDOC));
1544
0
                        aDlg.SetMinLen(0);
1545
0
                        aDlg.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_DOC)->GetCommand());
1546
0
                        aDlg.SetEditHelpId(HID_PASSWD_DOC);
1547
1548
0
                        if (aDlg.run() == RET_OK)
1549
0
                            aPassword = aDlg.GetPassword();
1550
0
                        else
1551
0
                            bCancel = true;
1552
0
                    }
1553
0
                    if (!bCancel)
1554
0
                    {
1555
0
                        Unprotect( TABLEID_DOC, aPassword );
1556
0
                        rReq.AppendItem( SfxBoolItem( FID_PROTECT_DOC, false ) );
1557
0
                        rReq.Done();
1558
0
                    }
1559
0
                }
1560
0
                else
1561
0
                {
1562
0
                    OUString aText(ScResId(SCSTR_PASSWORDOPT));
1563
1564
0
                    SfxPasswordDialog aDlg(GetFrameWeld(), &aText);
1565
0
                    aDlg.set_title(ScResId(SCSTR_PROTECTDOC));
1566
0
                    aDlg.SetMinLen( 0 );
1567
0
                    aDlg.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_DOC)->GetCommand());
1568
0
                    aDlg.SetEditHelpId(HID_PASSWD_DOC);
1569
0
                    aDlg.ShowExtras(SfxShowExtras::CONFIRM);
1570
0
                    aDlg.SetConfirmHelpId(HID_PASSWD_DOC_CONFIRM);
1571
1572
0
                    if (aDlg.run() == RET_OK)
1573
0
                    {
1574
0
                        OUString aPassword = aDlg.GetPassword();
1575
0
                        ProtectDoc( aPassword );
1576
0
                        rReq.AppendItem( SfxBoolItem( FID_PROTECT_DOC, true ) );
1577
0
                        rReq.Done();
1578
0
                    }
1579
0
                }
1580
0
                rBindings.Invalidate( FID_PROTECT_DOC );
1581
0
            }
1582
0
            break;
1583
1584
0
        case FID_PROTECT_TABLE:
1585
0
            ExecProtectTable( rReq );
1586
0
            break;
1587
1588
0
        case SID_APPLY_THEME:
1589
0
        {
1590
0
            const SfxItemSet* pArgs = rReq.GetArgs();
1591
0
            if (pArgs)
1592
0
            {
1593
0
                const SfxPoolItem* pItem;
1594
0
                if (pArgs->GetItemState(FN_PARAM_1, true, &pItem) == SfxItemState::SET)
1595
0
                {
1596
0
                    OUString aThemeName = static_cast<const SfxStringItem*>(pItem)->GetValue();
1597
0
                    auto pColorSet = svx::ColorSets::get().getColorSet(aThemeName);
1598
1599
0
                    if (pColorSet)
1600
0
                    {
1601
                        // Create shared pointer from raw pointer
1602
0
                        auto pSharedColorSet = std::shared_ptr<model::ColorSet>(new model::ColorSet(*pColorSet));
1603
0
                        sc::ThemeColorChanger aChanger(*GetViewData().GetDocShell());
1604
0
                        aChanger.apply(pSharedColorSet);
1605
0
                    }
1606
0
                }
1607
0
            }
1608
1609
0
            rReq.Done();
1610
0
        }
1611
0
        break;
1612
1613
0
        case SID_THEME_DIALOG:
1614
0
        {
1615
0
            MakeDrawLayer();
1616
0
            ScViewData& rViewData = GetViewData();
1617
0
            ScDocument& rDocument = rViewData.GetDocument();
1618
0
            ScDrawLayer* pModel = rDocument.GetDrawLayer();
1619
0
            auto const& pTheme = pModel->getTheme();
1620
0
            if (pTheme)
1621
0
            {
1622
0
                vcl::Window* pWin = rViewData.GetActiveWin();
1623
0
                auto pDialog = std::make_shared<svx::ThemeDialog>(pWin ? pWin->GetFrameWeld() : nullptr, pTheme.get());
1624
0
                weld::DialogController::runAsync(pDialog, [this, pDialog](sal_uInt32 nResult) {
1625
0
                    if (RET_OK != nResult)
1626
0
                        return;
1627
1628
0
                    auto pColorSet = pDialog->getCurrentColorSet();
1629
0
                    if (pColorSet)
1630
0
                    {
1631
0
                        sc::ThemeColorChanger aChanger(*GetViewData().GetDocShell());
1632
0
                        aChanger.apply(pColorSet);
1633
0
                    }
1634
0
                });
1635
0
            }
1636
0
            rReq.Done();
1637
0
        }
1638
0
        break;
1639
0
        case SID_OPT_LOCALE_CHANGED :
1640
0
            {   // locale changed, SYSTEM number formats changed => repaint cell contents
1641
0
                PaintGrid();
1642
0
                rReq.Done();
1643
0
            }
1644
0
            break;
1645
1646
0
        default:
1647
0
            OSL_FAIL("Unknown Slot at ScTabViewShell::Execute");
1648
0
            break;
1649
0
    }
1650
0
}
1651
1652
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */