Coverage Report

Created: 2025-12-08 09:28

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