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