1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
33 #include <globstr.hrc>
34 #include <strings.hrc>
36 #include <appoptio.hxx>
37 #include <tabvwsh.hxx>
38 #include <document.hxx>
41 #include <inputwin.hxx>
42 #include <scresid.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>
51 #include <svl/ilstitem.hxx>
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>
64 #include <basegfx/utils/zoomtools.hxx>
66 #include <svx/dialog/ThemeDialog.hxx>
67 #include <ThemeColorChanger.hxx>
71 void collectUIInformation(const OUString
& aZoom
)
73 EventDescription aDescription
;
74 aDescription
.aID
= "grid_window";
75 aDescription
.aParameters
= {{"ZOOM", aZoom
}};
76 aDescription
.aAction
= "SET";
77 aDescription
.aKeyWord
= "ScGridWinUIObject";
78 aDescription
.aParent
= "MainWindow";
79 UITestLogger::getInstance().logEvent(aDescription
);
82 enum class DetectFlags
89 struct ScRefFlagsAndType
92 DetectFlags eDetected
;
95 ScRefFlagsAndType
lcl_ParseRangeOrAddress(ScRange
& rScRange
, ScAddress
& rScAddress
,
96 const OUString
& aAddress
, const ScDocument
& rDoc
,
97 SCCOL nCurCol
, SCROW nCurRow
)
99 ScRefFlagsAndType aRet
;
101 // Relative address parsing needs current position.
102 // row,col parameters, not col,row!
103 ScAddress::Details
aDetails( rDoc
.GetAddressConvention(), nCurRow
, nCurCol
);
105 // start with the address convention set in the document
106 aRet
.nResult
= rScRange
.Parse(aAddress
, rDoc
, aDetails
);
107 if (aRet
.nResult
& ScRefFlags::VALID
)
109 aRet
.eDetected
= DetectFlags::RANGE
;
113 aRet
.nResult
= rScAddress
.Parse(aAddress
, rDoc
, aDetails
);
114 if (aRet
.nResult
& ScRefFlags::VALID
)
116 aRet
.eDetected
= DetectFlags::ADDRESS
;
120 // try the default Calc (A1) address convention
121 aRet
.nResult
= rScRange
.Parse(aAddress
, rDoc
);
122 if (aRet
.nResult
& ScRefFlags::VALID
)
124 aRet
.eDetected
= DetectFlags::RANGE
;
128 aRet
.nResult
= rScAddress
.Parse(aAddress
, rDoc
);
129 if (aRet
.nResult
& ScRefFlags::VALID
)
131 aRet
.eDetected
= DetectFlags::ADDRESS
;
135 // try the Excel A1 address convention
136 aRet
.nResult
= rScRange
.Parse(aAddress
, rDoc
, formula::FormulaGrammar::CONV_XL_A1
);
137 if (aRet
.nResult
& ScRefFlags::VALID
)
139 aRet
.eDetected
= DetectFlags::RANGE
;
143 // try the Excel A1 address convention
144 aRet
.nResult
= rScAddress
.Parse(aAddress
, rDoc
, formula::FormulaGrammar::CONV_XL_A1
);
145 if (aRet
.nResult
& ScRefFlags::VALID
)
147 aRet
.eDetected
= DetectFlags::ADDRESS
;
151 // try Excel R1C1 address convention
152 aDetails
.eConv
= formula::FormulaGrammar::CONV_XL_R1C1
;
153 aRet
.nResult
= rScRange
.Parse(aAddress
, rDoc
, aDetails
);
154 if (aRet
.nResult
& ScRefFlags::VALID
)
156 aRet
.eDetected
= DetectFlags::RANGE
;
160 aRet
.nResult
= rScAddress
.Parse(aAddress
, rDoc
, aDetails
);
161 if (aRet
.nResult
& ScRefFlags::VALID
)
163 aRet
.eDetected
= DetectFlags::ADDRESS
;
167 aRet
.nResult
= ScRefFlags::ZERO
;
168 aRet
.eDetected
= DetectFlags::NONE
;
174 void ScTabViewShell::FinishProtectTable()
177 UpdateInputHandler(true); // to immediately enable input again
181 void ScTabViewShell::ExecProtectTable( SfxRequest
& rReq
)
183 ScModule
* pScMod
= ScModule::get();
184 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
185 ScDocument
& rDoc
= GetViewData().GetDocument();
186 SCTAB nTab
= GetViewData().GetTabNo();
187 bool bOldProtection
= rDoc
.IsTabProtected(nTab
);
191 const SfxPoolItem
* pItem
;
192 bool bNewProtection
= !bOldProtection
;
193 if( pReqArgs
->HasItem( FID_PROTECT_TABLE
, &pItem
) )
194 bNewProtection
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
195 if( bNewProtection
== bOldProtection
)
204 // Unprotect a protected sheet.
206 const ScTableProtection
* pProtect
= rDoc
.GetTabProtection(nTab
);
207 if (pProtect
&& pProtect
->isProtectedWithPass())
209 std::shared_ptr
<SfxRequest
> xRequest
;
212 xRequest
= std::make_shared
<SfxRequest
>(rReq
);
213 rReq
.Ignore(); // the 'old' request is not relevant any more
216 OUString
aText( ScResId(SCSTR_PASSWORDOPT
) );
217 auto pDlg
= std::make_shared
<SfxPasswordDialog
>(GetFrameWeld(), &aText
);
218 pDlg
->set_title(ScResId(SCSTR_UNPROTECTTAB
));
220 pDlg
->set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_TABLE
)->GetCommand());
221 pDlg
->SetEditHelpId(HID_PASSWD_TABLE
);
225 weld::DialogController::runAsync(pDlg
, [this, nTab
, pDlg
,
226 xRequest
=std::move(xRequest
)](sal_Int32 response
) {
227 if (response
== RET_OK
)
229 OUString aPassword
= pDlg
->GetPassword();
230 Unprotect(nTab
, aPassword
);
234 xRequest
->AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, false) );
237 FinishProtectTable();
242 // this sheet is not password-protected.
243 Unprotect(nTab
, OUString());
247 rReq
.AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, false) );
253 // Protect a current sheet.
254 std::shared_ptr
<SfxRequest
> xRequest
;
257 xRequest
= std::make_shared
<SfxRequest
>(rReq
);
258 rReq
.Ignore(); // the 'old' request is not relevant any more
261 auto pDlg
= std::make_shared
<ScTableProtectionDlg
>(GetFrameWeld());
263 const ScTableProtection
* pProtect
= rDoc
.GetTabProtection(nTab
);
265 pDlg
->SetDialogData(*pProtect
);
266 weld::DialogController::runAsync(pDlg
, [this, pDlg
, pScMod
, nTab
,
267 xRequest
=std::move(xRequest
)](sal_uInt32 nResult
) {
268 if (nResult
== RET_OK
)
270 pScMod
->InputEnterHandler();
272 ScTableProtection aNewProtect
;
273 pDlg
->WriteData(aNewProtect
);
274 ProtectSheet(nTab
, aNewProtect
);
277 xRequest
->AppendItem( SfxBoolItem(FID_PROTECT_TABLE
, true) );
281 FinishProtectTable();
285 FinishProtectTable();
288 void ScTabViewShell::Execute( SfxRequest
& rReq
)
290 SfxViewFrame
& rThisFrame
= GetViewFrame();
291 SfxBindings
& rBindings
= rThisFrame
.GetBindings();
292 ScModule
* pScMod
= ScModule::get();
293 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
294 sal_uInt16 nSlot
= rReq
.GetSlot();
296 if (nSlot
!= SID_CURRENTCELL
) // comes with MouseButtonUp
297 HideListBox(); // Autofilter-DropDown-Listbox
301 case FID_INSERT_FILE
:
303 const SfxPoolItem
* pItem
;
305 pReqArgs
->GetItemState(FID_INSERT_FILE
,true,&pItem
) == SfxItemState::SET
)
307 OUString aFileName
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
312 if ( pReqArgs
->GetItemState(FN_PARAM_1
,true,&pItem
) == SfxItemState::SET
)
313 aInsertPos
= static_cast<const SfxPointItem
*>(pItem
)->GetValue();
315 aInsertPos
= GetInsertPos();
319 bool bAsLink
= false;
320 if ( pReqArgs
->GetItemState(FN_PARAM_2
,true,&pItem
) == SfxItemState::SET
)
321 bAsLink
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
325 PasteFile( aInsertPos
, aFileName
, bAsLink
);
330 case SID_OPENDLG_EDIT_PRINTAREA
:
332 sal_uInt16 nId
= ScPrintAreasDlgWrapper::GetChildWindowId();
333 SfxChildWindow
* pWnd
= rThisFrame
.GetChildWindow( nId
);
335 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
339 case SID_CHANGE_PRINTAREA
:
341 if ( pReqArgs
) // OK from dialog
346 bool bEntire
= false;
347 const SfxPoolItem
* pItem
;
348 if ( pReqArgs
->GetItemState( SID_CHANGE_PRINTAREA
, true, &pItem
) == SfxItemState::SET
)
349 aPrintStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
350 if ( pReqArgs
->GetItemState( FN_PARAM_2
, true, &pItem
) == SfxItemState::SET
)
351 aRowStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
352 if ( pReqArgs
->GetItemState( FN_PARAM_3
, true, &pItem
) == SfxItemState::SET
)
353 aColStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
354 if ( pReqArgs
->GetItemState( FN_PARAM_4
, true, &pItem
) == SfxItemState::SET
)
355 bEntire
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
357 SetPrintRanges( bEntire
, &aPrintStr
, &aColStr
, &aRowStr
, false );
364 case SID_ADD_PRINTAREA
:
365 case SID_DEFINE_PRINTAREA
: // menu or basic
367 bool bAdd
= ( nSlot
== SID_ADD_PRINTAREA
);
371 const SfxPoolItem
* pItem
;
372 if ( pReqArgs
->GetItemState( SID_DEFINE_PRINTAREA
, true, &pItem
) == SfxItemState::SET
)
373 aPrintStr
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
374 SetPrintRanges( false, &aPrintStr
, nullptr, nullptr, bAdd
);
378 SetPrintRanges( false, nullptr, nullptr, nullptr, bAdd
); // from selection
384 case SID_DELETE_PRINTAREA
:
386 // Clear currently defined print range if any, and reset it to
387 // print entire sheet which is the default.
389 SetPrintRanges(true, &aEmpty
, nullptr, nullptr, false);
394 case FID_DEL_MANUALBREAKS
:
395 RemoveManualBreaks();
399 case FID_ADJUST_PRINTZOOM
:
404 case FID_RESET_PRINTZOOM
:
405 SetPrintZoom( 100 ); // 100%, not on pages
410 case SID_STATUS_PAGESTYLE
:
412 GetViewData().GetDocShell()->
413 ExecutePageStyle( *this, rReq
, GetViewData().GetTabNo() );
417 case SID_CURRENTCELL
:
421 const SfxPoolItem
* pItem
;
422 if ( pReqArgs
->GetItemState( nSlot
, true, &pItem
) == SfxItemState::SET
)
423 aAddress
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
424 else if ( nSlot
== SID_JUMPTOMARK
&& pReqArgs
->GetItemState(
425 SID_JUMPTOMARK
, true, &pItem
) == SfxItemState::SET
)
426 aAddress
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
428 // #i14927# SID_CURRENTCELL with a single cell must unmark if FN_PARAM_1
429 // isn't set (for recorded macros, because IsAPI is no longer available).
430 // ScGridWindow::MouseButtonUp no longer executes the slot for a single
431 // cell if there is a multi selection.
432 bool bUnmark
= ( nSlot
== SID_CURRENTCELL
);
433 if ( pReqArgs
->GetItemState( FN_PARAM_1
, true, &pItem
) == SfxItemState::SET
)
434 bUnmark
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
436 bool bAlignToCursor
= true;
437 if (pReqArgs
->GetItemState(FN_PARAM_2
, true, &pItem
) == SfxItemState::SET
)
438 bAlignToCursor
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
440 bool bForceGlobalName
= false;
441 if (pReqArgs
->GetItemState(FN_PARAM_3
, true, &pItem
) == SfxItemState::SET
)
442 bForceGlobalName
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
444 if ( nSlot
== SID_JUMPTOMARK
)
446 // URL has to be decoded for escaped characters (%20)
447 aAddress
= INetURLObject::decode( aAddress
,
448 INetURLObject::DecodeMechanism::WithCharset
);
452 ScViewData
& rViewData
= GetViewData();
453 ScDocument
& rDoc
= rViewData
.GetDocument();
454 ScMarkData
& rMark
= rViewData
.GetMarkData();
456 ScAddress aScAddress
;
457 ScRefFlagsAndType aResult
= lcl_ParseRangeOrAddress(aScRange
, aScAddress
, aAddress
, rDoc
,
458 rViewData
.GetCurX(), rViewData
.GetCurY());
459 ScRefFlags nResult
= aResult
.nResult
;
460 SCTAB nTab
= rViewData
.GetTabNo();
464 if (aResult
.eDetected
== DetectFlags::RANGE
)
466 if ( nResult
& ScRefFlags::TAB_3D
)
468 if( aScRange
.aStart
.Tab() != nTab
)
470 nTab
= aScRange
.aStart
.Tab();
476 aScRange
.aStart
.SetTab( nTab
);
477 aScRange
.aEnd
.SetTab( nTab
);
481 else if (aResult
.eDetected
== DetectFlags::ADDRESS
)
483 if ( nResult
& ScRefFlags::TAB_3D
)
485 if( aScAddress
.Tab() != nTab
)
487 nTab
= aScAddress
.Tab();
492 aScAddress
.SetTab( nTab
);
494 aScRange
= ScRange( aScAddress
, aScAddress
);
495 // cells should not be marked
498 // Is it a named area (first named ranges then database ranges)?
501 const RutlNameScope eScope
= (bForceGlobalName
? RUTL_NAMES_GLOBAL
: RUTL_NAMES
);
502 ScAddress::Details
aDetails( rDoc
.GetAddressConvention(), rViewData
.GetCurY(), rViewData
.GetCurX());
503 if (ScRangeUtil::MakeRangeFromName( aAddress
, rDoc
, nTab
, aScRange
, eScope
, aDetails
, true) ||
504 ScRangeUtil::MakeRangeFromName( aAddress
, rDoc
, nTab
, aScRange
, RUTL_DBASE
, aDetails
, true))
506 nResult
|= ScRefFlags::VALID
;
507 if( aScRange
.aStart
.Tab() != nTab
)
509 nTab
= aScRange
.aStart
.Tab();
515 if ( !(nResult
& ScRefFlags::VALID
) && comphelper::string::isdigitAsciiString(aAddress
) )
517 sal_Int32 nNumeric
= aAddress
.toInt32();
518 if ( nNumeric
> 0 && nNumeric
<= rDoc
.MaxRow()+1 )
520 // one-based row numbers
522 aScAddress
.SetRow( static_cast<SCROW
>(nNumeric
- 1) );
523 aScAddress
.SetCol( rViewData
.GetCurX() );
524 aScAddress
.SetTab( nTab
);
525 aScRange
= ScRange( aScAddress
, aScAddress
);
527 nResult
= ScRefFlags::VALID
;
531 if ( !rDoc
.ValidRow(aScRange
.aStart
.Row()) || !rDoc
.ValidRow(aScRange
.aEnd
.Row()) )
532 nResult
= ScRefFlags::ZERO
;
534 // we have found something
535 if( nResult
& ScRefFlags::VALID
)
538 SCCOL nCol
= aScRange
.aStart
.Col();
539 SCROW nRow
= aScRange
.aStart
.Row();
540 bool bNothing
= ( rViewData
.GetCurX()==nCol
&& rViewData
.GetCurY()==nRow
);
545 if (rMark
.IsMarked()) // is the same range already marked?
547 ScRange aOldMark
= rMark
.GetMarkArea();
548 aOldMark
.PutInOrder();
549 ScRange aCurrent
= aScRange
;
550 aCurrent
.PutInOrder();
551 bNothing
= ( aCurrent
== aOldMark
);
557 MarkRange( aScRange
, false ); // cursor comes after...
561 // remove old selection, unless bUnmark argument is sal_False (from navigator)
564 MoveCursorAbs( nCol
, nRow
,
565 SC_FOLLOW_NONE
, false, false );
571 // consider merged cells:
572 rDoc
.SkipOverlapped(nCol
, nRow
, nTab
);
574 // navigator calls are not part of the API!!!
579 rReq
.Ignore(); // if macro, then nothing
581 rReq
.Done(); // then at least paint it
585 rViewData
.ResetOldCursor();
586 SetCursor( nCol
, nRow
);
587 rBindings
.Invalidate( SID_CURRENTCELL
);
588 rBindings
.Update( nSlot
);
596 // align to cursor even if the cursor position hasn't changed,
597 // because the cursor may be set outside the visible area.
598 AlignToCursor( nCol
, nRow
, SC_FOLLOW_JUMP
);
599 if ( nSlot
== SID_JUMPTOMARK
&& comphelper::LibreOfficeKit::isActive() )
600 rViewData
.GetActiveWin()->notifyKitCellFollowJump();
603 rReq
.SetReturnValue( SfxStringItem( SID_CURRENTCELL
, aAddress
) );
606 if (!bFound
) // no valid range
608 // if it is a sheet name, then switch (for Navigator/URL)
611 if ( rDoc
.GetTable( aAddress
, nNameTab
) )
614 if ( nNameTab
!= nTab
)
615 SetTabNo( nNameTab
);
619 if ( !bFound
&& nSlot
== SID_JUMPTOMARK
)
621 // test graphics objects (only for URL)
623 bFound
= SelectObject( aAddress
);
626 if (!bFound
&& !rReq
.IsAPI())
627 ErrorMessage( STR_ERR_INVALID_AREA
);
631 case SID_CURRENTOBJECT
:
634 OUString aName
= static_cast<const SfxStringItem
&>(pReqArgs
->Get(nSlot
)).GetValue();
635 SelectObject( aName
);
642 ScViewData
& rViewData
= GetViewData();
643 ScDocument
& rDoc
= rViewData
.GetDocument();
644 SCTAB nTabCount
= rDoc
.GetTableCount();
645 if ( pReqArgs
) // command from Navigator with nTab
647 // sheet for basic is one-based
648 nTab
= static_cast<const SfxUInt16Item
&>(pReqArgs
->Get(nSlot
)).GetValue() - 1;
650 else // command from Menu: ask for nTab
652 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
654 ScopedVclPtr
<AbstractScGoToTabDlg
> pDlg(pFact
->CreateScGoToTabDlg(GetFrameWeld()));
655 pDlg
->SetDescription(
656 ScResId( STR_DLG_SELECTTABLE_TITLE
),
657 ScResId( STR_DLG_SELECTTABLE_MASK
),
658 ScResId( STR_DLG_SELECTTABLE_LBNAME
),
659 GetStaticInterface()->GetSlot(SID_CURRENTTAB
)->GetCommand(), HID_GOTOTABLEMASK
, HID_GOTOTABLE
);
661 // fill all table names and select current tab
663 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
665 if( rDoc
.IsVisible( nTab
) )
667 rDoc
.GetName( nTab
, aTabName
);
668 pDlg
->Insert( aTabName
, rViewData
.GetTabNo() == nTab
);
672 if( pDlg
->Execute() == RET_OK
)
674 if( !rDoc
.GetTable( pDlg
->GetSelectedEntry(), nTab
) )
676 pDlg
.disposeAndClear();
683 if ( nTab
< nTabCount
)
686 rBindings
.Update( nSlot
);
691 //! otherwise an error ?
698 OUString
aStrDocName( static_cast<const SfxStringItem
&>(pReqArgs
->
699 Get(nSlot
)).GetValue() );
701 SfxViewFrame
* pViewFrame
= nullptr;
702 ScDocShell
* pDocSh
= static_cast<ScDocShell
*>(SfxObjectShell::GetFirst());
705 // search for ViewFrame to be activated
707 while ( pDocSh
&& !bFound
)
709 if ( pDocSh
->GetTitle() == aStrDocName
)
711 pViewFrame
= SfxViewFrame::GetFirst( pDocSh
);
712 bFound
= ( nullptr != pViewFrame
);
715 pDocSh
= static_cast<ScDocShell
*>(SfxObjectShell::GetNext( *pDocSh
));
719 pViewFrame
->GetFrame().Appear();
721 rReq
.Ignore();//XXX is handled by SFX
725 case SID_PRINTPREVIEW
:
727 if ( !rThisFrame
.GetFrame().IsInPlace() ) // not for OLE
729 // print preview is now always in the same frame as the tab view
730 // -> always switch this frame back to normal view
731 // (ScPreviewShell ctor reads view data)
733 // #102785#; finish input
734 pScMod
->InputEnterHandler();
736 rThisFrame
.GetDispatcher()->Execute( SID_VIEWSHELL1
, SfxCallMode::ASYNCHRON
);
738 // else error (e.g. Ole)
742 case SID_DETECTIVE_DEL_ALL
:
747 // SID_TABLE_ACTIVATE and SID_MARKAREA are called by basic for the
748 // hidden View, to mark/switch on the visible View:
750 case SID_TABLE_ACTIVATE
:
751 OSL_FAIL("old slot SID_TABLE_ACTIVATE");
762 case FID_NORMALVIEWMODE
:
763 case FID_PAGEBREAKMODE
:
765 bool bWantPageBreak
= nSlot
== FID_PAGEBREAKMODE
;
767 // check whether there is an explicit argument, use it
768 const SfxPoolItem
* pItem
;
769 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
)
771 bool bItemValue
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
772 bWantPageBreak
= (nSlot
== FID_PAGEBREAKMODE
) == bItemValue
;
775 if( GetViewData().IsPagebreakMode() != bWantPageBreak
)
777 SetPagebreakMode( bWantPageBreak
);
778 UpdatePageBreakData();
779 SetCurSubShell( GetCurObjectSelectionType(), true );
783 rBindings
.Invalidate( nSlot
);
784 rReq
.AppendItem( SfxBoolItem( nSlot
, true ) );
790 case FID_FUNCTION_BOX
:
792 // First make sure that the sidebar is visible
793 rThisFrame
.ShowChildWindow(SID_SIDEBAR
);
795 ::sfx2::sidebar::Sidebar::ShowPanel(u
"ScFunctionsPanel",
796 rThisFrame
.GetFrame().GetFrameInterface(),
802 case FID_TOGGLESYNTAX
:
804 bool bSet
= !GetViewData().IsSyntaxMode();
805 const SfxPoolItem
* pItem
;
806 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
)
807 bSet
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
808 GetViewData().SetSyntaxMode( bSet
);
810 rBindings
.Invalidate( FID_TOGGLESYNTAX
);
811 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
815 case FID_HANDLEDUPLICATERECORDS
:
817 using namespace com::sun::star
;
818 table::CellRangeAddress aCellRange
;
819 uno::Reference
<sheet::XSpreadsheet
> xActiveSheet
;
820 DuplicatesResponse aResponse
;
821 bool bHasData
= true;
825 const SfxPoolItem
* pItem
;
827 if (pReqArgs
->HasItem(FID_HANDLEDUPLICATERECORDS
, &pItem
))
828 aResponse
.bRemove
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
829 if (pReqArgs
->HasItem(FN_PARAM_1
, &pItem
))
830 aResponse
.bIncludesHeaders
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
831 if (pReqArgs
->HasItem(FN_PARAM_2
, &pItem
))
832 aResponse
.bDuplicateRows
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
833 if (pReqArgs
->HasItem(FN_PARAM_3
, &pItem
))
834 aCellRange
.StartColumn
= static_cast<const SfxInt32Item
*>(pItem
)->GetValue();
835 if (pReqArgs
->HasItem(FN_PARAM_4
, &pItem
))
836 aCellRange
.StartRow
= static_cast<const SfxInt32Item
*>(pItem
)->GetValue();
837 if (pReqArgs
->HasItem(FN_PARAM_5
, &pItem
))
838 aCellRange
.EndColumn
= static_cast<const SfxInt32Item
*>(pItem
)->GetValue();
839 if (pReqArgs
->HasItem(FN_PARAM_6
, &pItem
))
840 aCellRange
.EndRow
= static_cast<const SfxInt32Item
*>(pItem
)->GetValue();
841 if (pReqArgs
->HasItem(FN_PARAM_7
, &pItem
))
842 aCellRange
.Sheet
= static_cast<const SfxInt32Item
*>(pItem
)->GetValue();
844 // check for the tab range here
845 if (aCellRange
.StartColumn
< 0 || aCellRange
.StartRow
< 0
846 || aCellRange
.EndColumn
< 0 || aCellRange
.EndRow
< 0
847 || aCellRange
.StartRow
> aCellRange
.EndRow
848 || aCellRange
.StartColumn
> aCellRange
.EndColumn
|| aCellRange
.Sheet
< 0
849 || aCellRange
.Sheet
>= GetViewData().GetDocument().GetTableCount())
854 xActiveSheet
= GetViewData().GetViewShell()->GetRangeWithSheet(aCellRange
,
862 = (aResponse
.bDuplicateRows
? aCellRange
.EndColumn
- aCellRange
.StartColumn
863 : aCellRange
.EndRow
- aCellRange
.StartRow
);
864 for (int i
= 0; i
<= nLenEntries
; ++i
)
865 aResponse
.vEntries
.push_back(i
);
869 xActiveSheet
= GetViewData().GetViewShell()->GetRangeWithSheet(aCellRange
,
873 if (!GetViewData().GetMarkData().IsMarked())
874 GetViewData().GetViewShell()->ExtendSingleSelection(aCellRange
);
876 uno::Reference
<frame::XModel
> xModel(GetViewData().GetDocShell()->GetModel());
877 uno::Reference
<sheet::XSheetCellRange
> xSheetRange(
878 xActiveSheet
->getCellRangeByPosition(
879 aCellRange
.StartColumn
, aCellRange
.StartRow
, aCellRange
.EndColumn
,
883 ScRange
aRange(ScAddress(aCellRange
.StartColumn
, aCellRange
.StartRow
,
884 GetViewData().GetTabNo()),
885 ScAddress(aCellRange
.EndColumn
, aCellRange
.EndRow
,
886 GetViewData().GetTabNo()));
888 uno::Reference
<sheet::XCellRangeData
> xCellRangeData(xSheetRange
,
890 uno::Sequence
<uno::Sequence
<uno::Any
>> aDataArray
891 = xCellRangeData
->getDataArray();
893 ScDuplicateRecordsDlg
aDlg(GetFrameWeld(), aDataArray
, GetViewData(), aRange
);
895 bHasData
= aDlg
.run();
897 aResponse
= aDlg
.GetDialogData();
906 std::unique_ptr
<weld::MessageDialog
> aDialog(
907 Application::CreateMessageDialog(GetFrameWeld(),
908 VclMessageType::Warning
,
910 ScResId(STR_DUPLICATERECORDSDLG_NODATAFOUND
)));
911 aDialog
->set_title(ScResId(STR_DUPLICATERECORDSDLG_WARNING
));
917 GetViewData().GetViewShell()->HandleDuplicateRecords(
918 xActiveSheet
, aCellRange
, aResponse
.bRemove
, aResponse
.bIncludesHeaders
,
919 aResponse
.bDuplicateRows
, aResponse
.vEntries
);
924 case FID_TOGGLECOLROWHIGHLIGHTING
:
926 bool bNewVal
= !officecfg::Office::Calc::Content::Display::ColumnRowHighlighting::get();
928 auto pChange(comphelper::ConfigurationChanges::create());
929 officecfg::Office::Calc::Content::Display::ColumnRowHighlighting::set(bNewVal
, pChange
);
932 rReq
.AppendItem(SfxBoolItem(nSlot
, bNewVal
));
936 case FID_TOGGLEHEADERS
:
938 bool bSet
= !GetViewData().IsHeaderMode();
939 const SfxPoolItem
* pItem
;
940 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
)
941 bSet
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
942 GetViewData().SetHeaderMode( bSet
);
944 rBindings
.Invalidate( FID_TOGGLEHEADERS
);
945 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
950 case FID_TOGGLEFORMULA
:
952 ScViewData
& rViewData
= GetViewData();
953 const ScViewOptions
& rOpts
= rViewData
.GetOptions();
954 bool bFormulaMode
= !rOpts
.GetOption( VOPT_FORMULAS
);
955 const SfxPoolItem
*pItem
;
956 if( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
)
957 bFormulaMode
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
959 ScViewOptions aSetOpts
= rOpts
;
960 aSetOpts
.SetOption( VOPT_FORMULAS
, bFormulaMode
);
961 rViewData
.SetOptions( aSetOpts
);
962 ScDocument
& rDoc
= rViewData
.GetDocument();
963 rDoc
.SetViewOptions(aSetOpts
);
965 rViewData
.GetDocShell()->PostPaintGridAll();
967 rBindings
.Invalidate( FID_TOGGLEFORMULA
);
968 rReq
.AppendItem( SfxBoolItem( nSlot
, bFormulaMode
) );
973 case FID_TOGGLEINPUTLINE
:
975 sal_uInt16 nId
= ScInputWindowWrapper::GetChildWindowId();
976 SfxChildWindow
* pWnd
= rThisFrame
.GetChildWindow( nId
);
977 bool bSet
= ( pWnd
== nullptr );
978 const SfxPoolItem
* pItem
;
979 if ( pReqArgs
&& pReqArgs
->GetItemState(nSlot
, true, &pItem
) == SfxItemState::SET
)
980 bSet
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
982 rThisFrame
.SetChildWindow( nId
, bSet
);
983 rBindings
.Invalidate( FID_TOGGLEINPUTLINE
);
984 rReq
.AppendItem( SfxBoolItem( nSlot
, bSet
) );
989 // handling for SID_ZOOM_IN and SID_ZOOM_OUT is ScTabView::ScrollCommand
990 // CommandWheelMode::ZOOM inspired
996 if (!GetViewData().GetViewShell()->GetViewFrame().GetFrame().IsInPlace())
998 // for ole inplace editing, the scale is defined by the visarea and client size
999 // and can't be changed directly
1001 const Fraction
& rOldY
= GetViewData().GetZoomY();
1002 sal_uInt16 nOld
= tools::Long(rOldY
* 100);
1004 if (SID_ZOOM_OUT
== nSlot
)
1005 nNew
= std::max(MINZOOM
, basegfx::zoomtools::zoomOut(nOld
));
1007 nNew
= std::min(MAXZOOM
, basegfx::zoomtools::zoomIn(nOld
));
1010 bool bSyncZoom
= pScMod
->GetAppOptions().GetSynchronizeZoom();
1011 SetZoomType(SvxZoomType::PERCENT
, bSyncZoom
);
1012 Fraction
aFract(nNew
, 100);
1013 SetZoom(aFract
, aFract
, bSyncZoom
);
1017 rBindings
.Invalidate(SID_ATTR_ZOOM
);
1018 rBindings
.Invalidate(SID_ATTR_ZOOMSLIDER
);
1019 rBindings
.Invalidate(SID_ZOOM_IN
);
1020 rBindings
.Invalidate(SID_ZOOM_OUT
);
1027 case SID_ATTR_ZOOM
: // status row
1030 bool bSyncZoom
= pScMod
->GetAppOptions().GetSynchronizeZoom();
1031 SvxZoomType eOldZoomType
= GetZoomType();
1032 SvxZoomType eNewZoomType
= eOldZoomType
;
1033 const Fraction
& rOldY
= GetViewData().GetZoomY(); // Y is shown
1034 sal_uInt16 nOldZoom
= static_cast<sal_uInt16
>(tools::Long( rOldY
* 100 ));
1035 sal_uInt16 nZoom
= nOldZoom
;
1036 bool bCancel
= false;
1040 const SvxZoomItem
& rZoomItem
= pReqArgs
->Get(SID_ATTR_ZOOM
);
1042 eNewZoomType
= rZoomItem
.GetType();
1043 nZoom
= rZoomItem
.GetValue();
1047 SfxItemSetFixed
<SID_ATTR_ZOOM
, SID_ATTR_ZOOM
> aSet( GetPool() );
1048 SvxZoomItem
aZoomItem( eOldZoomType
, nOldZoom
, SID_ATTR_ZOOM
);
1049 ScopedVclPtr
<AbstractSvxZoomDialog
> pDlg
;
1050 ScMarkData
& rMark
= GetViewData().GetMarkData();
1051 SvxZoomEnableFlags nBtnFlags
= SvxZoomEnableFlags::N50
1052 | SvxZoomEnableFlags::N75
1053 | SvxZoomEnableFlags::N100
1054 | SvxZoomEnableFlags::N150
1055 | SvxZoomEnableFlags::N200
1056 | SvxZoomEnableFlags::WHOLEPAGE
1057 | SvxZoomEnableFlags::PAGEWIDTH
;
1059 if ( rMark
.IsMarked() || rMark
.IsMultiMarked() )
1060 nBtnFlags
= nBtnFlags
| SvxZoomEnableFlags::OPTIMAL
;
1062 aZoomItem
.SetValueSet( nBtnFlags
);
1063 aSet
.Put( aZoomItem
);
1064 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1065 pDlg
.disposeAndReset(pFact
->CreateSvxZoomDialog(GetFrameWeld(), aSet
));
1066 pDlg
->SetLimits( MINZOOM
, MAXZOOM
);
1068 bCancel
= ( RET_CANCEL
== pDlg
->Execute() );
1070 // bCancel is True only if we were in the previous if block,
1071 // so no need to check again pDlg
1074 const SvxZoomItem
& rZoomItem
= pDlg
->GetOutputItemSet()->
1075 Get( SID_ATTR_ZOOM
);
1077 eNewZoomType
= rZoomItem
.GetType();
1078 nZoom
= rZoomItem
.GetValue();
1084 if ( eNewZoomType
== SvxZoomType::PERCENT
)
1086 if ( nZoom
< MINZOOM
) nZoom
= MINZOOM
;
1087 if ( nZoom
> MAXZOOM
) nZoom
= MAXZOOM
;
1091 nZoom
= CalcZoom( eNewZoomType
, nOldZoom
);
1092 bCancel
= nZoom
== 0;
1095 switch ( eNewZoomType
)
1097 case SvxZoomType::WHOLEPAGE
:
1098 case SvxZoomType::PAGEWIDTH
:
1099 SetZoomType( eNewZoomType
, bSyncZoom
);
1103 SetZoomType( SvxZoomType::PERCENT
, bSyncZoom
);
1107 if ( nZoom
!= nOldZoom
&& !bCancel
)
1109 if (!GetViewData().IsPagebreakMode())
1111 ScAppOptions aNewOpt
= pScMod
->GetAppOptions();
1112 aNewOpt
.SetZoom( nZoom
);
1113 aNewOpt
.SetZoomType( GetZoomType() );
1114 pScMod
->SetAppOptions( aNewOpt
);
1116 Fraction
aFract( nZoom
, 100 );
1117 SetZoom( aFract
, aFract
, bSyncZoom
);
1121 rBindings
.Invalidate( SID_ATTR_ZOOM
);
1122 rReq
.AppendItem( SvxZoomItem( GetZoomType(), nZoom
, TypedWhichId
<SvxZoomItem
>(nSlot
) ) );
1128 case SID_ATTR_ZOOMSLIDER
:
1130 const SfxPoolItem
* pItem
= nullptr;
1131 bool bSyncZoom
= pScMod
->GetAppOptions().GetSynchronizeZoom();
1132 if ( pReqArgs
&& pReqArgs
->GetItemState(SID_ATTR_ZOOMSLIDER
, true, &pItem
) == SfxItemState::SET
)
1134 const sal_uInt16 nCurrentZoom
= static_cast<const SvxZoomSliderItem
*>(pItem
)->GetValue();
1137 SetZoomType( SvxZoomType::PERCENT
, bSyncZoom
);
1138 if (!GetViewData().IsPagebreakMode())
1140 ScAppOptions aNewOpt
= pScMod
->GetAppOptions();
1141 aNewOpt
.SetZoom( nCurrentZoom
);
1142 collectUIInformation(OUString::number(nCurrentZoom
));
1143 aNewOpt
.SetZoomType( GetZoomType() );
1144 pScMod
->SetAppOptions( aNewOpt
);
1146 Fraction
aFract( nCurrentZoom
,100 );
1147 SetZoom( aFract
, aFract
, bSyncZoom
);
1151 rBindings
.Invalidate( SID_ATTR_ZOOMSLIDER
);
1152 rBindings
.Invalidate( SID_ZOOM_IN
);
1153 rBindings
.Invalidate( SID_ZOOM_OUT
);
1160 case FID_TAB_SELECTALL
:
1165 case FID_TAB_DESELECTALL
:
1166 DeselectAllTables();
1170 case SID_SELECT_TABLES
:
1172 ScViewData
& rViewData
= GetViewData();
1173 ScDocument
& rDoc
= rViewData
.GetDocument();
1174 ScMarkData
& rMark
= rViewData
.GetMarkData();
1175 SCTAB nTabCount
= rDoc
.GetTableCount();
1178 ::std::vector
< sal_Int32
> aIndexList
;
1179 const SfxIntegerListItem
* pItem
= rReq
.GetArg
<SfxIntegerListItem
>(SID_SELECT_TABLES
);
1181 aIndexList
= pItem
->GetList();
1184 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
1186 ScopedVclPtr
<AbstractScShowTabDlg
> pDlg(pFact
->CreateScShowTabDlg(GetFrameWeld()));
1187 pDlg
->SetDescription(
1188 ScResId( STR_DLG_SELECTTABLES_TITLE
),
1189 ScResId( STR_DLG_SELECTTABLES_LBNAME
),
1190 GetStaticInterface()->GetSlot(SID_SELECT_TABLES
)->GetCommand(), HID_SELECTTABLES
);
1192 // fill all table names with selection state
1194 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
1196 rDoc
.GetName( nTab
, aTabName
);
1197 pDlg
->Insert( aTabName
, rMark
.GetTableSelect( nTab
) );
1200 if( pDlg
->Execute() == RET_OK
)
1202 aIndexList
= pDlg
->GetSelectedRows();
1203 pDlg
.disposeAndClear();
1204 rReq
.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES
, std::vector(aIndexList
) ) );
1210 if ( !aIndexList
.empty() )
1212 sal_uInt16 nSelCount
= aIndexList
.size();
1214 SCTAB nFirstVisTab
= 0;
1216 // special case: only hidden tables selected -> do nothing
1217 bool bVisSelected
= false;
1218 for( nSelIx
= 0; !bVisSelected
&& (nSelIx
< nSelCount
); ++nSelIx
)
1220 nFirstVisTab
= static_cast<SCTAB
>(aIndexList
[nSelIx
]);
1221 bVisSelected
= rDoc
.IsVisible( nFirstVisTab
);
1226 // select the tables
1229 for( nTab
= 0; nTab
< nTabCount
; ++nTab
)
1230 rMark
.SelectTable( nTab
, false );
1232 for( nSelIx
= 0; nSelIx
< nSelCount
; ++nSelIx
)
1233 rMark
.SelectTable( static_cast<SCTAB
>(aIndexList
[nSelIx
]), true );
1235 // activate another table, if current is deselected
1236 if( !rMark
.GetTableSelect( rViewData
.GetTabNo() ) )
1238 rMark
.SelectTable( nFirstVisTab
, true );
1239 SetTabNo( nFirstVisTab
);
1242 rViewData
.GetDocShell()->PostPaintExtras();
1243 SfxBindings
& rBind
= rViewData
.GetBindings();
1244 rBind
.Invalidate( FID_FILL_TAB
);
1245 rBind
.Invalidate( FID_TAB_DESELECTALL
);
1253 case SID_OUTLINE_DELETEALL
:
1254 RemoveAllOutlines();
1258 case SID_AUTO_OUTLINE
:
1263 case SID_WINDOW_SPLIT
:
1265 ScSplitMode eHSplit
= GetViewData().GetHSplitMode();
1266 ScSplitMode eVSplit
= GetViewData().GetVSplitMode();
1267 if ( eHSplit
== SC_SPLIT_NORMAL
|| eVSplit
== SC_SPLIT_NORMAL
) // remove
1269 else if ( eHSplit
== SC_SPLIT_FIX
|| eVSplit
== SC_SPLIT_FIX
) // normal
1270 FreezeSplitters( false );
1279 case SID_WINDOW_FIX
:
1281 if (!comphelper::LibreOfficeKit::isActive())
1283 ScSplitMode eHSplit
= GetViewData().GetHSplitMode();
1284 ScSplitMode eVSplit
= GetViewData().GetVSplitMode();
1285 if ( eHSplit
== SC_SPLIT_FIX
|| eVSplit
== SC_SPLIT_FIX
) // remove
1288 FreezeSplitters( true, SC_SPLIT_METHOD_CURSOR
); // create or fixate
1294 ScViewData
& rViewData
= GetViewData();
1295 SCTAB nThisTab
= rViewData
.GetTabNo();
1296 bool bChangedX
= false, bChangedY
= false;
1297 if (rViewData
.GetLOKSheetFreezeIndex(true) > 0 ||
1298 rViewData
.GetLOKSheetFreezeIndex(false) > 0 ) // remove freeze
1300 bChangedX
= rViewData
.RemoveLOKFreeze();
1301 } // create or fixate
1304 bChangedX
= rViewData
.SetLOKSheetFreezeIndex(rViewData
.GetCurX(), true); // Freeze column
1305 bChangedY
= rViewData
.SetLOKSheetFreezeIndex(rViewData
.GetCurY(), false); // Freeze row
1309 if (bChangedX
|| bChangedY
)
1311 rBindings
.Invalidate( SID_WINDOW_FIX
);
1312 rBindings
.Invalidate( SID_WINDOW_FIX_COL
);
1313 rBindings
.Invalidate( SID_WINDOW_FIX_ROW
);
1314 // Invalidate the slot for all views on the same tab of the document.
1315 SfxLokHelper::forEachOtherView(this, [nThisTab
](ScTabViewShell
* pOther
) {
1316 ScViewData
& rOtherViewData
= pOther
->GetViewData();
1317 if (rOtherViewData
.GetTabNo() != nThisTab
)
1320 SfxBindings
& rOtherBind
= rOtherViewData
.GetBindings();
1321 rOtherBind
.Invalidate( SID_WINDOW_FIX
);
1322 rOtherBind
.Invalidate( SID_WINDOW_FIX_COL
);
1323 rOtherBind
.Invalidate( SID_WINDOW_FIX_ROW
);
1325 if (!GetViewData().GetDocShell()->IsReadOnly())
1326 GetViewData().GetDocShell()->SetDocumentModified();
1332 case SID_WINDOW_FIX_COL
:
1333 case SID_WINDOW_FIX_ROW
:
1335 bool bIsCol
= (nSlot
== SID_WINDOW_FIX_COL
);
1336 sal_Int32 nFreezeIndex
= 1;
1337 if (const SfxInt32Item
* pItem
= rReq
.GetArg
<SfxInt32Item
>(FN_PARAM_1
))
1339 nFreezeIndex
= pItem
->GetValue();
1340 if (nFreezeIndex
< 0)
1344 if (comphelper::LibreOfficeKit::isActive())
1346 ScViewData
& rViewData
= GetViewData();
1347 SCTAB nThisTab
= rViewData
.GetTabNo();
1348 bool bChanged
= rViewData
.SetLOKSheetFreezeIndex(nFreezeIndex
, bIsCol
);
1352 rBindings
.Invalidate( SID_WINDOW_FIX
);
1353 rBindings
.Invalidate(nSlot
);
1354 // Invalidate the slot for all views on the same tab of the document.
1355 SfxLokHelper::forEachOtherView(this, [nSlot
, nThisTab
](ScTabViewShell
* pOther
) {
1356 ScViewData
& rOtherViewData
= pOther
->GetViewData();
1357 if (rOtherViewData
.GetTabNo() != nThisTab
)
1360 SfxBindings
& rOtherBind
= rOtherViewData
.GetBindings();
1361 rOtherBind
.Invalidate( SID_WINDOW_FIX
);
1362 rOtherBind
.Invalidate(nSlot
);
1364 if (!GetViewData().GetDocShell()->IsReadOnly())
1365 GetViewData().GetDocShell()->SetDocumentModified();
1370 FreezeSplitters( true, bIsCol
? SC_SPLIT_METHOD_COL
: SC_SPLIT_METHOD_ROW
, nFreezeIndex
);
1379 sal_uInt16 nId
= ScHighlightChgDlgWrapper::GetChildWindowId();
1380 SfxChildWindow
* pWnd
= rThisFrame
.GetChildWindow( nId
);
1382 pScMod
->SetRefDialog( nId
, pWnd
== nullptr );
1386 case FID_CHG_ACCEPT
:
1388 rThisFrame
.ToggleChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId());
1389 GetViewFrame().GetBindings().Invalidate(FID_CHG_ACCEPT
);
1393 sal_uInt16 nId = ScAcceptChgDlgWrapper::GetChildWindowId();
1394 SfxChildWindow* pWnd = rThisFrame.GetChildWindow( nId );
1396 pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True );
1401 case FID_CHG_COMMENT
:
1403 ScViewData
& rData
= GetViewData();
1404 ScAddress
aCursorPos( rData
.GetCurX(), rData
.GetCurY(), rData
.GetTabNo() );
1405 ScDocShell
* pDocSh
= rData
.GetDocShell();
1407 ScChangeAction
* pAction
= pDocSh
->GetChangeAction( aCursorPos
);
1410 const SfxPoolItem
* pItem
;
1412 pReqArgs
->GetItemState( nSlot
, true, &pItem
) == SfxItemState::SET
&&
1413 dynamic_cast<const SfxStringItem
*>( pItem
) != nullptr )
1415 OUString aComment
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
1416 pDocSh
->SetChangeComment( pAction
, aComment
);
1421 pDocSh
->ExecuteChangeCommentDialog(pAction
, GetFrameWeld());
1428 case SID_CREATE_SW_DRAWVIEW
:
1429 // is called by Forms, when the DrawView has to be created with all
1431 if (!GetScDrawView())
1433 GetViewData().GetDocShell()->MakeDrawLayer();
1434 rBindings
.InvalidateAll(false);
1438 case FID_PROTECT_DOC
:
1440 ScDocument
& rDoc
= GetViewData().GetDocument();
1444 const SfxPoolItem
* pItem
;
1445 if( pReqArgs
->HasItem( FID_PROTECT_DOC
, &pItem
) &&
1446 static_cast<const SfxBoolItem
*>(pItem
)->GetValue() == rDoc
.IsDocProtected() )
1453 ScDocProtection
* pProtect
= rDoc
.GetDocProtection();
1454 if (pProtect
&& pProtect
->isProtected())
1456 bool bCancel
= false;
1459 if (pProtect
->isProtectedWithPass())
1461 OUString
aText(ScResId(SCSTR_PASSWORD
));
1463 SfxPasswordDialog
aDlg(GetFrameWeld(), &aText
);
1464 aDlg
.set_title(ScResId(SCSTR_UNPROTECTDOC
));
1466 aDlg
.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_DOC
)->GetCommand());
1467 aDlg
.SetEditHelpId(HID_PASSWD_DOC
);
1469 if (aDlg
.run() == RET_OK
)
1470 aPassword
= aDlg
.GetPassword();
1476 Unprotect( TABLEID_DOC
, aPassword
);
1477 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_DOC
, false ) );
1483 OUString
aText(ScResId(SCSTR_PASSWORDOPT
));
1485 SfxPasswordDialog
aDlg(GetFrameWeld(), &aText
);
1486 aDlg
.set_title(ScResId(SCSTR_PROTECTDOC
));
1487 aDlg
.SetMinLen( 0 );
1488 aDlg
.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_DOC
)->GetCommand());
1489 aDlg
.SetEditHelpId(HID_PASSWD_DOC
);
1490 aDlg
.ShowExtras(SfxShowExtras::CONFIRM
);
1491 aDlg
.SetConfirmHelpId(HID_PASSWD_DOC_CONFIRM
);
1493 if (aDlg
.run() == RET_OK
)
1495 OUString aPassword
= aDlg
.GetPassword();
1496 ProtectDoc( aPassword
);
1497 rReq
.AppendItem( SfxBoolItem( FID_PROTECT_DOC
, true ) );
1501 rBindings
.Invalidate( FID_PROTECT_DOC
);
1505 case FID_PROTECT_TABLE
:
1506 ExecProtectTable( rReq
);
1509 case SID_THEME_DIALOG
:
1512 ScViewData
& rViewData
= GetViewData();
1513 ScDocument
& rDocument
= rViewData
.GetDocument();
1514 ScDrawLayer
* pModel
= rDocument
.GetDrawLayer();
1515 auto const& pTheme
= pModel
->getTheme();
1518 vcl::Window
* pWin
= rViewData
.GetActiveWin();
1519 auto pDialog
= std::make_shared
<svx::ThemeDialog
>(pWin
? pWin
->GetFrameWeld() : nullptr, pTheme
.get());
1520 weld::DialogController::runAsync(pDialog
, [this, pDialog
](sal_uInt32 nResult
) {
1521 if (RET_OK
!= nResult
)
1524 auto pColorSet
= pDialog
->getCurrentColorSet();
1527 sc::ThemeColorChanger
aChanger(*GetViewData().GetDocShell());
1528 aChanger
.apply(pColorSet
);
1535 case SID_OPT_LOCALE_CHANGED
:
1536 { // locale changed, SYSTEM number formats changed => repaint cell contents
1543 OSL_FAIL("Unknown Slot at ScTabViewShell::Execute");
1548 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */