File: | home/maarten/src/libreoffice/core/include/rtl/ref.hxx |
Warning: | line 192, column 9 Use of memory after it is freed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||||||||
2 | /* | ||||||||
3 | * This file is part of the LibreOffice project. | ||||||||
4 | * | ||||||||
5 | * This Source Code Form is subject to the terms of the Mozilla Public | ||||||||
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||||||||
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||||||
8 | * | ||||||||
9 | * This file incorporates work covered by the following license notice: | ||||||||
10 | * | ||||||||
11 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||
12 | * contributor license agreements. See the NOTICE file distributed | ||||||||
13 | * with this work for additional information regarding copyright | ||||||||
14 | * ownership. The ASF licenses this file to you under the Apache | ||||||||
15 | * License, Version 2.0 (the "License"); you may not use this file | ||||||||
16 | * except in compliance with the License. You may obtain a copy of | ||||||||
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||||||||
18 | */ | ||||||||
19 | |||||||||
20 | #include <sfx2/bindings.hxx> | ||||||||
21 | #include <sfx2/dispatch.hxx> | ||||||||
22 | #include <sfx2/passwd.hxx> | ||||||||
23 | #include <sfx2/request.hxx> | ||||||||
24 | #include <sfx2/sidebar/Sidebar.hxx> | ||||||||
25 | #include <svl/ptitem.hxx> | ||||||||
26 | #include <svl/stritem.hxx> | ||||||||
27 | #include <tools/urlobj.hxx> | ||||||||
28 | #include <sfx2/objface.hxx> | ||||||||
29 | #include <vcl/vclenum.hxx> | ||||||||
30 | #include <vcl/uitest/logger.hxx> | ||||||||
31 | #include <vcl/uitest/eventdescription.hxx> | ||||||||
32 | |||||||||
33 | #include <globstr.hrc> | ||||||||
34 | #include <strings.hrc> | ||||||||
35 | #include <scmod.hxx> | ||||||||
36 | #include <appoptio.hxx> | ||||||||
37 | #include <tabvwsh.hxx> | ||||||||
38 | #include <document.hxx> | ||||||||
39 | #include <sc.hrc> | ||||||||
40 | #include <helpids.h> | ||||||||
41 | #include <inputwin.hxx> | ||||||||
42 | #include <scresid.hxx> | ||||||||
43 | #include <docsh.hxx> | ||||||||
44 | #include <rangeutl.hxx> | ||||||||
45 | #include <reffact.hxx> | ||||||||
46 | #include <tabprotection.hxx> | ||||||||
47 | #include <protectiondlg.hxx> | ||||||||
48 | #include <markdata.hxx> | ||||||||
49 | |||||||||
50 | #include <svl/ilstitem.hxx> | ||||||||
51 | #include <vector> | ||||||||
52 | |||||||||
53 | #include <svx/zoomslideritem.hxx> | ||||||||
54 | #include <svx/svxdlg.hxx> | ||||||||
55 | #include <comphelper/lok.hxx> | ||||||||
56 | #include <comphelper/string.hxx> | ||||||||
57 | #include <sfx2/lokhelper.hxx> | ||||||||
58 | #include <scabstdlg.hxx> | ||||||||
59 | |||||||||
60 | namespace | ||||||||
61 | { | ||||||||
62 | void collectUIInformation(const OUString& aZoom) | ||||||||
63 | { | ||||||||
64 | EventDescription aDescription; | ||||||||
65 | aDescription.aID = "grid_window"; | ||||||||
66 | aDescription.aParameters = {{"ZOOM", aZoom}}; | ||||||||
67 | aDescription.aAction = "SET"; | ||||||||
68 | aDescription.aKeyWord = "ScGridWinUIObject"; | ||||||||
69 | aDescription.aParent = "MainWindow"; | ||||||||
70 | UITestLogger::getInstance().logEvent(aDescription); | ||||||||
71 | } | ||||||||
72 | |||||||||
73 | enum class DetectFlags | ||||||||
74 | { | ||||||||
75 | NONE, | ||||||||
76 | RANGE, | ||||||||
77 | ADDRESS | ||||||||
78 | }; | ||||||||
79 | |||||||||
80 | struct ScRefFlagsAndType | ||||||||
81 | { | ||||||||
82 | ScRefFlags nResult; | ||||||||
83 | DetectFlags eDetected; | ||||||||
84 | }; | ||||||||
85 | |||||||||
86 | ScRefFlagsAndType lcl_ParseRangeOrAddress(ScRange& rScRange, ScAddress& rScAddress, | ||||||||
87 | const OUString& aAddress, const ScDocument& rDoc) | ||||||||
88 | { | ||||||||
89 | ScRefFlagsAndType aRet; | ||||||||
90 | |||||||||
91 | formula::FormulaGrammar::AddressConvention eConv; | ||||||||
92 | |||||||||
93 | // start with the address convention set in the document | ||||||||
94 | eConv = rDoc.GetAddressConvention(); | ||||||||
95 | aRet.nResult = rScRange.Parse(aAddress, rDoc, eConv); | ||||||||
96 | if (aRet.nResult & ScRefFlags::VALID) | ||||||||
97 | { | ||||||||
98 | aRet.eDetected = DetectFlags::RANGE; | ||||||||
99 | return aRet; | ||||||||
100 | } | ||||||||
101 | |||||||||
102 | aRet.nResult = rScAddress.Parse(aAddress, rDoc, eConv); | ||||||||
103 | if (aRet.nResult & ScRefFlags::VALID) | ||||||||
104 | { | ||||||||
105 | aRet.eDetected = DetectFlags::ADDRESS; | ||||||||
106 | return aRet; | ||||||||
107 | } | ||||||||
108 | |||||||||
109 | // try the default Calc (A1) address convention | ||||||||
110 | aRet.nResult = rScRange.Parse(aAddress, rDoc); | ||||||||
111 | if (aRet.nResult & ScRefFlags::VALID) | ||||||||
112 | { | ||||||||
113 | aRet.eDetected = DetectFlags::RANGE; | ||||||||
114 | return aRet; | ||||||||
115 | } | ||||||||
116 | |||||||||
117 | aRet.nResult = rScAddress.Parse(aAddress, rDoc); | ||||||||
118 | if (aRet.nResult & ScRefFlags::VALID) | ||||||||
119 | { | ||||||||
120 | aRet.eDetected = DetectFlags::ADDRESS; | ||||||||
121 | return aRet; | ||||||||
122 | } | ||||||||
123 | |||||||||
124 | // try the Excel A1 address convention | ||||||||
125 | aRet.nResult = rScRange.Parse(aAddress, rDoc, formula::FormulaGrammar::CONV_XL_A1); | ||||||||
126 | if (aRet.nResult & ScRefFlags::VALID) | ||||||||
127 | { | ||||||||
128 | aRet.eDetected = DetectFlags::RANGE; | ||||||||
129 | return aRet; | ||||||||
130 | } | ||||||||
131 | |||||||||
132 | // try the Excel A1 address convention | ||||||||
133 | aRet.nResult = rScAddress.Parse(aAddress, rDoc, formula::FormulaGrammar::CONV_XL_A1); | ||||||||
134 | if (aRet.nResult & ScRefFlags::VALID) | ||||||||
135 | { | ||||||||
136 | aRet.eDetected = DetectFlags::ADDRESS; | ||||||||
137 | return aRet; | ||||||||
138 | } | ||||||||
139 | |||||||||
140 | // try Excel R1C1 address convention | ||||||||
141 | aRet.nResult = rScRange.Parse(aAddress, rDoc, formula::FormulaGrammar::CONV_XL_R1C1); | ||||||||
142 | if (aRet.nResult & ScRefFlags::VALID) | ||||||||
143 | { | ||||||||
144 | aRet.eDetected = DetectFlags::RANGE; | ||||||||
145 | return aRet; | ||||||||
146 | } | ||||||||
147 | |||||||||
148 | aRet.nResult = rScAddress.Parse(aAddress, rDoc, formula::FormulaGrammar::CONV_XL_R1C1); | ||||||||
149 | if (aRet.nResult & ScRefFlags::VALID) | ||||||||
150 | { | ||||||||
151 | aRet.eDetected = DetectFlags::ADDRESS; | ||||||||
152 | return aRet; | ||||||||
153 | } | ||||||||
154 | |||||||||
155 | aRet.nResult = ScRefFlags::ZERO; | ||||||||
156 | aRet.eDetected = DetectFlags::NONE; | ||||||||
157 | |||||||||
158 | return aRet; | ||||||||
159 | } | ||||||||
160 | } | ||||||||
161 | |||||||||
162 | void ScTabViewShell::Execute( SfxRequest& rReq ) | ||||||||
163 | { | ||||||||
164 | SfxViewFrame* pThisFrame = GetViewFrame(); | ||||||||
165 | SfxBindings& rBindings = pThisFrame->GetBindings(); | ||||||||
166 | ScModule* pScMod = SC_MOD()( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule ::Calc)) ); | ||||||||
167 | const SfxItemSet* pReqArgs = rReq.GetArgs(); | ||||||||
168 | sal_uInt16 nSlot = rReq.GetSlot(); | ||||||||
169 | |||||||||
170 | if (nSlot != SID_CURRENTCELL((26000) + 41)) // comes with MouseButtonUp | ||||||||
| |||||||||
171 | HideListBox(); // Autofilter-DropDown-Listbox | ||||||||
172 | |||||||||
173 | switch ( nSlot ) | ||||||||
174 | { | ||||||||
175 | case FID_INSERT_FILE((((26000 + 521) + 50))+53): | ||||||||
176 | { | ||||||||
177 | const SfxPoolItem* pItem; | ||||||||
178 | if ( pReqArgs && | ||||||||
179 | pReqArgs->GetItemState(FID_INSERT_FILE((((26000 + 521) + 50))+53),true,&pItem) == SfxItemState::SET ) | ||||||||
180 | { | ||||||||
181 | OUString aFileName = static_cast<const SfxStringItem*>(pItem)->GetValue(); | ||||||||
182 | |||||||||
183 | // insert position | ||||||||
184 | |||||||||
185 | Point aInsertPos; | ||||||||
186 | if ( pReqArgs->GetItemState(FN_PARAM_1((20000 + 1100)+60),true,&pItem) == SfxItemState::SET ) | ||||||||
187 | aInsertPos = static_cast<const SfxPointItem*>(pItem)->GetValue(); | ||||||||
188 | else | ||||||||
189 | aInsertPos = GetInsertPos(); | ||||||||
190 | |||||||||
191 | // as Link? | ||||||||
192 | |||||||||
193 | bool bAsLink = false; | ||||||||
194 | if ( pReqArgs->GetItemState(FN_PARAM_2((20000 + 1100)+61),true,&pItem) == SfxItemState::SET ) | ||||||||
195 | bAsLink = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | ||||||||
196 | |||||||||
197 | // execute | ||||||||
198 | |||||||||
199 | PasteFile( aInsertPos, aFileName, bAsLink ); | ||||||||
200 | } | ||||||||
201 | } | ||||||||
202 | break; | ||||||||
203 | |||||||||
204 | case SID_OPENDLG_EDIT_PRINTAREA((((26000 + 521) + 50))+34): | ||||||||
205 | { | ||||||||
206 | sal_uInt16 nId = ScPrintAreasDlgWrapper::GetChildWindowId(); | ||||||||
207 | SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId ); | ||||||||
208 | |||||||||
209 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | ||||||||
210 | } | ||||||||
211 | break; | ||||||||
212 | |||||||||
213 | case SID_CHANGE_PRINTAREA((((26000 + 521) + 50))+33): | ||||||||
214 | { | ||||||||
215 | if ( pReqArgs ) // OK from dialog | ||||||||
216 | { | ||||||||
217 | OUString aPrintStr; | ||||||||
218 | OUString aRowStr; | ||||||||
219 | OUString aColStr; | ||||||||
220 | bool bEntire = false; | ||||||||
221 | const SfxPoolItem* pItem; | ||||||||
222 | if ( pReqArgs->GetItemState( SID_CHANGE_PRINTAREA((((26000 + 521) + 50))+33), true, &pItem ) == SfxItemState::SET ) | ||||||||
223 | aPrintStr = static_cast<const SfxStringItem*>(pItem)->GetValue(); | ||||||||
224 | if ( pReqArgs->GetItemState( FN_PARAM_2((20000 + 1100)+61), true, &pItem ) == SfxItemState::SET ) | ||||||||
225 | aRowStr = static_cast<const SfxStringItem*>(pItem)->GetValue(); | ||||||||
226 | if ( pReqArgs->GetItemState( FN_PARAM_3((20000 + 1100)+62), true, &pItem ) == SfxItemState::SET ) | ||||||||
227 | aColStr = static_cast<const SfxStringItem*>(pItem)->GetValue(); | ||||||||
228 | if ( pReqArgs->GetItemState( FN_PARAM_4((20000 + 1100)+63), true, &pItem ) == SfxItemState::SET ) | ||||||||
229 | bEntire = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | ||||||||
230 | |||||||||
231 | SetPrintRanges( bEntire, &aPrintStr, &aColStr, &aRowStr, false ); | ||||||||
232 | |||||||||
233 | rReq.Done(); | ||||||||
234 | } | ||||||||
235 | } | ||||||||
236 | break; | ||||||||
237 | |||||||||
238 | case SID_ADD_PRINTAREA((((26000 + 521) + 50))+80): | ||||||||
239 | case SID_DEFINE_PRINTAREA((((26000 + 521) + 50))+31): // menu or basic | ||||||||
240 | { | ||||||||
241 | bool bAdd = ( nSlot == SID_ADD_PRINTAREA((((26000 + 521) + 50))+80) ); | ||||||||
242 | if ( pReqArgs ) | ||||||||
243 | { | ||||||||
244 | OUString aPrintStr; | ||||||||
245 | const SfxPoolItem* pItem; | ||||||||
246 | if ( pReqArgs->GetItemState( SID_DEFINE_PRINTAREA((((26000 + 521) + 50))+31), true, &pItem ) == SfxItemState::SET ) | ||||||||
247 | aPrintStr = static_cast<const SfxStringItem*>(pItem)->GetValue(); | ||||||||
248 | SetPrintRanges( false, &aPrintStr, nullptr, nullptr, bAdd ); | ||||||||
249 | } | ||||||||
250 | else | ||||||||
251 | { | ||||||||
252 | SetPrintRanges( false, nullptr, nullptr, nullptr, bAdd ); // from selection | ||||||||
253 | rReq.Done(); | ||||||||
254 | } | ||||||||
255 | } | ||||||||
256 | break; | ||||||||
257 | |||||||||
258 | case SID_DELETE_PRINTAREA((((26000 + 521) + 50))+32): | ||||||||
259 | { | ||||||||
260 | // Clear currently defined print range if any, and reset it to | ||||||||
261 | // print entire sheet which is the default. | ||||||||
262 | OUString aEmpty; | ||||||||
263 | SetPrintRanges(true, &aEmpty, nullptr, nullptr, false); | ||||||||
264 | rReq.Done(); | ||||||||
265 | } | ||||||||
266 | break; | ||||||||
267 | |||||||||
268 | case FID_DEL_MANUALBREAKS((((26000 + 521) + 50))+79): | ||||||||
269 | RemoveManualBreaks(); | ||||||||
270 | rReq.Done(); | ||||||||
271 | break; | ||||||||
272 | |||||||||
273 | case FID_ADJUST_PRINTZOOM((((26000 + 521) + 50))+81): | ||||||||
274 | AdjustPrintZoom(); | ||||||||
275 | rReq.Done(); | ||||||||
276 | break; | ||||||||
277 | |||||||||
278 | case FID_RESET_PRINTZOOM((((26000 + 521) + 50))+82): | ||||||||
279 | SetPrintZoom( 100 ); // 100%, not on pages | ||||||||
280 | rReq.Done(); | ||||||||
281 | break; | ||||||||
282 | |||||||||
283 | case SID_FORMATPAGE((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 17): | ||||||||
284 | case SID_STATUS_PAGESTYLE((26000 + 100) + 15): | ||||||||
285 | case SID_HFEDIT((((26000 + 200) + 20)) + 15): | ||||||||
286 | GetViewData().GetDocShell()-> | ||||||||
287 | ExecutePageStyle( *this, rReq, GetViewData().GetTabNo() ); | ||||||||
288 | break; | ||||||||
289 | |||||||||
290 | case SID_JUMPTOMARK(5000 + 598): | ||||||||
291 | case SID_CURRENTCELL((26000) + 41): | ||||||||
292 | if ( pReqArgs ) | ||||||||
293 | { | ||||||||
294 | OUString aAddress; | ||||||||
295 | const SfxPoolItem* pItem; | ||||||||
296 | if ( pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET ) | ||||||||
297 | aAddress = static_cast<const SfxStringItem*>(pItem)->GetValue(); | ||||||||
298 | else if ( nSlot == SID_JUMPTOMARK(5000 + 598) && pReqArgs->GetItemState( | ||||||||
299 | SID_JUMPTOMARK(5000 + 598), true, &pItem ) == SfxItemState::SET ) | ||||||||
300 | aAddress = static_cast<const SfxStringItem*>(pItem)->GetValue(); | ||||||||
301 | |||||||||
302 | // #i14927# SID_CURRENTCELL with a single cell must unmark if FN_PARAM_1 | ||||||||
303 | // isn't set (for recorded macros, because IsAPI is no longer available). | ||||||||
304 | // ScGridWindow::MouseButtonUp no longer executes the slot for a single | ||||||||
305 | // cell if there is a multi selection. | ||||||||
306 | bool bUnmark = ( nSlot == SID_CURRENTCELL((26000) + 41) ); | ||||||||
307 | if ( pReqArgs->GetItemState( FN_PARAM_1((20000 + 1100)+60), true, &pItem ) == SfxItemState::SET ) | ||||||||
308 | bUnmark = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | ||||||||
309 | |||||||||
310 | bool bAlignToCursor = true; | ||||||||
311 | if (pReqArgs->GetItemState(FN_PARAM_2((20000 + 1100)+61), true, &pItem) == SfxItemState::SET) | ||||||||
312 | bAlignToCursor = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | ||||||||
313 | |||||||||
314 | if ( nSlot == SID_JUMPTOMARK(5000 + 598) ) | ||||||||
315 | { | ||||||||
316 | // URL has to be decoded for escaped characters (%20) | ||||||||
317 | aAddress = INetURLObject::decode( aAddress, | ||||||||
318 | INetURLObject::DecodeMechanism::WithCharset ); | ||||||||
319 | } | ||||||||
320 | |||||||||
321 | bool bFound = false; | ||||||||
322 | ScViewData& rViewData = GetViewData(); | ||||||||
323 | ScDocument& rDoc = rViewData.GetDocument(); | ||||||||
324 | ScMarkData& rMark = rViewData.GetMarkData(); | ||||||||
325 | ScRange aScRange; | ||||||||
326 | ScAddress aScAddress; | ||||||||
327 | ScRefFlagsAndType aResult = lcl_ParseRangeOrAddress(aScRange, aScAddress, aAddress, rDoc); | ||||||||
328 | ScRefFlags nResult = aResult.nResult; | ||||||||
329 | SCTAB nTab = rViewData.GetTabNo(); | ||||||||
330 | bool bMark = true; | ||||||||
331 | |||||||||
332 | // Is this a range ? | ||||||||
333 | if (aResult.eDetected == DetectFlags::RANGE) | ||||||||
334 | { | ||||||||
335 | if ( nResult & ScRefFlags::TAB_3D ) | ||||||||
336 | { | ||||||||
337 | if( aScRange.aStart.Tab() != nTab ) | ||||||||
338 | { | ||||||||
339 | nTab = aScRange.aStart.Tab(); | ||||||||
340 | SetTabNo( nTab ); | ||||||||
341 | } | ||||||||
342 | } | ||||||||
343 | else | ||||||||
344 | { | ||||||||
345 | aScRange.aStart.SetTab( nTab ); | ||||||||
346 | aScRange.aEnd.SetTab( nTab ); | ||||||||
347 | } | ||||||||
348 | } | ||||||||
349 | // Is this a cell ? | ||||||||
350 | else if (aResult.eDetected == DetectFlags::ADDRESS) | ||||||||
351 | { | ||||||||
352 | if ( nResult & ScRefFlags::TAB_3D ) | ||||||||
353 | { | ||||||||
354 | if( aScAddress.Tab() != nTab ) | ||||||||
355 | { | ||||||||
356 | nTab = aScAddress.Tab(); | ||||||||
357 | SetTabNo( nTab ); | ||||||||
358 | } | ||||||||
359 | } | ||||||||
360 | else | ||||||||
361 | aScAddress.SetTab( nTab ); | ||||||||
362 | |||||||||
363 | aScRange = ScRange( aScAddress, aScAddress ); | ||||||||
364 | // cells should not be marked | ||||||||
365 | bMark = false; | ||||||||
366 | } | ||||||||
367 | // Is it a named area (first named ranges then database ranges)? | ||||||||
368 | else | ||||||||
369 | { | ||||||||
370 | formula::FormulaGrammar::AddressConvention eConv = rDoc.GetAddressConvention(); | ||||||||
371 | if( ScRangeUtil::MakeRangeFromName( aAddress, rDoc, nTab, aScRange, RUTL_NAMES, eConv ) || | ||||||||
372 | ScRangeUtil::MakeRangeFromName( aAddress, rDoc, nTab, aScRange, RUTL_DBASE, eConv ) ) | ||||||||
373 | { | ||||||||
374 | nResult |= ScRefFlags::VALID; | ||||||||
375 | if( aScRange.aStart.Tab() != nTab ) | ||||||||
376 | { | ||||||||
377 | nTab = aScRange.aStart.Tab(); | ||||||||
378 | SetTabNo( nTab ); | ||||||||
379 | } | ||||||||
380 | } | ||||||||
381 | } | ||||||||
382 | |||||||||
383 | if ( !(nResult & ScRefFlags::VALID) && comphelper::string::isdigitAsciiString(aAddress) ) | ||||||||
384 | { | ||||||||
385 | sal_Int32 nNumeric = aAddress.toInt32(); | ||||||||
386 | if ( nNumeric > 0 && nNumeric <= rDoc.MaxRow()+1 ) | ||||||||
387 | { | ||||||||
388 | // one-based row numbers | ||||||||
389 | |||||||||
390 | aScAddress.SetRow( static_cast<SCROW>(nNumeric - 1) ); | ||||||||
391 | aScAddress.SetCol( rViewData.GetCurX() ); | ||||||||
392 | aScAddress.SetTab( nTab ); | ||||||||
393 | aScRange = ScRange( aScAddress, aScAddress ); | ||||||||
394 | bMark = false; | ||||||||
395 | nResult = ScRefFlags::VALID; | ||||||||
396 | } | ||||||||
397 | } | ||||||||
398 | |||||||||
399 | if ( !rDoc.ValidRow(aScRange.aStart.Row()) || !rDoc.ValidRow(aScRange.aEnd.Row()) ) | ||||||||
400 | nResult = ScRefFlags::ZERO; | ||||||||
401 | |||||||||
402 | // we have found something | ||||||||
403 | if( nResult & ScRefFlags::VALID ) | ||||||||
404 | { | ||||||||
405 | bFound = true; | ||||||||
406 | SCCOL nCol = aScRange.aStart.Col(); | ||||||||
407 | SCROW nRow = aScRange.aStart.Row(); | ||||||||
408 | bool bNothing = ( rViewData.GetCurX()==nCol && rViewData.GetCurY()==nRow ); | ||||||||
409 | |||||||||
410 | // mark | ||||||||
411 | if( bMark ) | ||||||||
412 | { | ||||||||
413 | if (rMark.IsMarked()) // is the same range already marked? | ||||||||
414 | { | ||||||||
415 | ScRange aOldMark; | ||||||||
416 | rMark.GetMarkArea( aOldMark ); | ||||||||
417 | aOldMark.PutInOrder(); | ||||||||
418 | ScRange aCurrent = aScRange; | ||||||||
419 | aCurrent.PutInOrder(); | ||||||||
420 | bNothing = ( aCurrent == aOldMark ); | ||||||||
421 | } | ||||||||
422 | else | ||||||||
423 | bNothing = false; | ||||||||
424 | |||||||||
425 | if (!bNothing) | ||||||||
426 | MarkRange( aScRange, false ); // cursor comes after... | ||||||||
427 | } | ||||||||
428 | else | ||||||||
429 | { | ||||||||
430 | // remove old selection, unless bUnmark argument is sal_False (from navigator) | ||||||||
431 | if( bUnmark ) | ||||||||
432 | { | ||||||||
433 | MoveCursorAbs( nCol, nRow, | ||||||||
434 | SC_FOLLOW_NONE, false, false ); | ||||||||
435 | } | ||||||||
436 | } | ||||||||
437 | |||||||||
438 | // and set cursor | ||||||||
439 | |||||||||
440 | // consider merged cells: | ||||||||
441 | rDoc.SkipOverlapped(nCol, nRow, nTab); | ||||||||
442 | |||||||||
443 | // navigator calls are not part of the API!!! | ||||||||
444 | |||||||||
445 | if( bNothing ) | ||||||||
446 | { | ||||||||
447 | if (rReq.IsAPI()) | ||||||||
448 | rReq.Ignore(); // if macro, then nothing | ||||||||
449 | else | ||||||||
450 | rReq.Done(); // then at least paint it | ||||||||
451 | } | ||||||||
452 | else | ||||||||
453 | { | ||||||||
454 | rViewData.ResetOldCursor(); | ||||||||
455 | SetCursor( nCol, nRow ); | ||||||||
456 | rBindings.Invalidate( SID_CURRENTCELL((26000) + 41) ); | ||||||||
457 | rBindings.Update( nSlot ); | ||||||||
458 | |||||||||
459 | if (!rReq.IsAPI()) | ||||||||
460 | rReq.Done(); | ||||||||
461 | } | ||||||||
462 | |||||||||
463 | if (bAlignToCursor) | ||||||||
464 | { | ||||||||
465 | // align to cursor even if the cursor position hasn't changed, | ||||||||
466 | // because the cursor may be set outside the visible area. | ||||||||
467 | AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP ); | ||||||||
468 | } | ||||||||
469 | |||||||||
470 | rReq.SetReturnValue( SfxStringItem( SID_CURRENTCELL((26000) + 41), aAddress ) ); | ||||||||
471 | } | ||||||||
472 | |||||||||
473 | if (!bFound) // no valid range | ||||||||
474 | { | ||||||||
475 | // if it is a sheet name, then switch (for Navigator/URL) | ||||||||
476 | |||||||||
477 | SCTAB nNameTab; | ||||||||
478 | if ( rDoc.GetTable( aAddress, nNameTab ) ) | ||||||||
479 | { | ||||||||
480 | bFound = true; | ||||||||
481 | if ( nNameTab != nTab ) | ||||||||
482 | SetTabNo( nNameTab ); | ||||||||
483 | } | ||||||||
484 | } | ||||||||
485 | |||||||||
486 | if ( !bFound && nSlot == SID_JUMPTOMARK(5000 + 598) ) | ||||||||
487 | { | ||||||||
488 | // test graphics objects (only for URL) | ||||||||
489 | |||||||||
490 | bFound = SelectObject( aAddress ); | ||||||||
491 | } | ||||||||
492 | |||||||||
493 | if (!bFound && !rReq.IsAPI()) | ||||||||
494 | ErrorMessage( STR_ERR_INVALID_AREAreinterpret_cast<char const *>("STR_ERR_INVALID_AREA" "\004" u8"Invalid range") ); | ||||||||
495 | } | ||||||||
496 | break; | ||||||||
497 | |||||||||
498 | case SID_CURRENTOBJECT((26000) + 44): | ||||||||
499 | if ( pReqArgs ) | ||||||||
500 | { | ||||||||
501 | OUString aName = static_cast<const SfxStringItem&>(pReqArgs->Get(nSlot)).GetValue(); | ||||||||
502 | SelectObject( aName ); | ||||||||
503 | } | ||||||||
504 | break; | ||||||||
505 | |||||||||
506 | case SID_CURRENTTAB((26000) + 42): | ||||||||
507 | if ( pReqArgs ) | ||||||||
508 | { | ||||||||
509 | // sheet for basic is one-based | ||||||||
510 | SCTAB nTab = static_cast<const SfxUInt16Item&>(pReqArgs->Get(nSlot)).GetValue() - 1; | ||||||||
511 | ScDocument& rDoc = GetViewData().GetDocument(); | ||||||||
512 | if ( nTab < rDoc.GetTableCount() ) | ||||||||
513 | { | ||||||||
514 | SetTabNo( nTab ); | ||||||||
515 | rBindings.Update( nSlot ); | ||||||||
516 | |||||||||
517 | if( ! rReq.IsAPI() ) | ||||||||
518 | rReq.Done(); | ||||||||
519 | } | ||||||||
520 | //! otherwise an error ? | ||||||||
521 | } | ||||||||
522 | break; | ||||||||
523 | |||||||||
524 | case SID_CURRENTDOC((26000) + 43): | ||||||||
525 | if ( pReqArgs ) | ||||||||
526 | { | ||||||||
527 | OUString aStrDocName( static_cast<const SfxStringItem&>(pReqArgs-> | ||||||||
528 | Get(nSlot)).GetValue() ); | ||||||||
529 | |||||||||
530 | SfxViewFrame* pViewFrame = nullptr; | ||||||||
531 | ScDocShell* pDocSh = static_cast<ScDocShell*>(SfxObjectShell::GetFirst()); | ||||||||
532 | bool bFound = false; | ||||||||
533 | |||||||||
534 | // search for ViewFrame to be activated | ||||||||
535 | |||||||||
536 | while ( pDocSh && !bFound ) | ||||||||
537 | { | ||||||||
538 | if ( pDocSh->GetTitle() == aStrDocName ) | ||||||||
539 | { | ||||||||
540 | pViewFrame = SfxViewFrame::GetFirst( pDocSh ); | ||||||||
541 | bFound = ( nullptr != pViewFrame ); | ||||||||
542 | } | ||||||||
543 | |||||||||
544 | pDocSh = static_cast<ScDocShell*>(SfxObjectShell::GetNext( *pDocSh )); | ||||||||
545 | } | ||||||||
546 | |||||||||
547 | if ( bFound ) | ||||||||
548 | pViewFrame->GetFrame().Appear(); | ||||||||
549 | |||||||||
550 | rReq.Ignore();//XXX is handled by SFX | ||||||||
551 | } | ||||||||
552 | break; | ||||||||
553 | |||||||||
554 | case SID_PRINTPREVIEW(5000 + 325): | ||||||||
555 | { | ||||||||
556 | if ( !pThisFrame->GetFrame().IsInPlace() ) // not for OLE | ||||||||
557 | { | ||||||||
558 | // print preview is now always in the same frame as the tab view | ||||||||
559 | // -> always switch this frame back to normal view | ||||||||
560 | // (ScPreviewShell ctor reads view data) | ||||||||
561 | |||||||||
562 | // #102785#; finish input | ||||||||
563 | pScMod->InputEnterHandler(); | ||||||||
564 | |||||||||
565 | pThisFrame->GetDispatcher()->Execute( SID_VIEWSHELL1(5000 + 631), SfxCallMode::ASYNCHRON ); | ||||||||
566 | } | ||||||||
567 | // else error (e.g. Ole) | ||||||||
568 | } | ||||||||
569 | break; | ||||||||
570 | |||||||||
571 | case SID_DETECTIVE_DEL_ALL((((((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 29)) + 20))+20))+1))+50))+20))+5): | ||||||||
572 | DetectiveDelAll(); | ||||||||
573 | rReq.Done(); | ||||||||
574 | break; | ||||||||
575 | |||||||||
576 | // SID_TABLE_ACTIVATE and SID_MARKAREA are called by basic for the | ||||||||
577 | // hidden View, to mark/switch on the visible View: | ||||||||
578 | |||||||||
579 | case SID_TABLE_ACTIVATE((((26000 + 521) + 50))+27): | ||||||||
580 | OSL_FAIL("old slot SID_TABLE_ACTIVATE")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/view/tabvwsh3.cxx" ":" "580" ": "), "%s", "old slot SID_TABLE_ACTIVATE"); } } while (false); | ||||||||
581 | break; | ||||||||
582 | |||||||||
583 | case SID_REPAINT(26000 + 12): | ||||||||
584 | PaintGrid(); | ||||||||
585 | PaintTop(); | ||||||||
586 | PaintLeft(); | ||||||||
587 | PaintExtras(); | ||||||||
588 | rReq.Done(); | ||||||||
589 | break; | ||||||||
590 | |||||||||
591 | case FID_NORMALVIEWMODE((((((26000 + 200) + 20)) + 20)) + 9): | ||||||||
592 | case FID_PAGEBREAKMODE((((((26000 + 200) + 20)) + 20)) + 7): | ||||||||
593 | { | ||||||||
594 | bool bWantPageBreak = nSlot == FID_PAGEBREAKMODE((((((26000 + 200) + 20)) + 20)) + 7); | ||||||||
595 | |||||||||
596 | // check whether there is an explicit argument, use it | ||||||||
597 | const SfxPoolItem* pItem; | ||||||||
598 | if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET ) | ||||||||
599 | { | ||||||||
600 | bool bItemValue = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | ||||||||
601 | bWantPageBreak = (nSlot == FID_PAGEBREAKMODE((((((26000 + 200) + 20)) + 20)) + 7)) == bItemValue; | ||||||||
602 | } | ||||||||
603 | |||||||||
604 | if( GetViewData().IsPagebreakMode() != bWantPageBreak ) | ||||||||
605 | { | ||||||||
606 | SetPagebreakMode( bWantPageBreak ); | ||||||||
607 | UpdatePageBreakData(); | ||||||||
608 | SetCurSubShell( GetCurObjectSelectionType(), true ); | ||||||||
609 | PaintGrid(); | ||||||||
610 | PaintTop(); | ||||||||
611 | PaintLeft(); | ||||||||
612 | rBindings.Invalidate( nSlot ); | ||||||||
613 | rReq.AppendItem( SfxBoolItem( nSlot, true ) ); | ||||||||
614 | rReq.Done(); | ||||||||
615 | } | ||||||||
616 | } | ||||||||
617 | break; | ||||||||
618 | |||||||||
619 | case FID_FUNCTION_BOX((((((26000 + 200) + 20)) + 20)) + 8): | ||||||||
620 | { | ||||||||
621 | // First make sure that the sidebar is visible | ||||||||
622 | pThisFrame->ShowChildWindow(SID_SIDEBAR(10000 + 336)); | ||||||||
623 | |||||||||
624 | ::sfx2::sidebar::Sidebar::ShowPanel("ScFunctionsPanel", | ||||||||
625 | pThisFrame->GetFrame().GetFrameInterface()); | ||||||||
626 | rReq.Done (); | ||||||||
627 | } | ||||||||
628 | break; | ||||||||
629 | |||||||||
630 | case FID_TOGGLESYNTAX((((((26000 + 200) + 20)) + 20)) + 5): | ||||||||
631 | { | ||||||||
632 | bool bSet = !GetViewData().IsSyntaxMode(); | ||||||||
633 | const SfxPoolItem* pItem; | ||||||||
634 | if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET ) | ||||||||
635 | bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | ||||||||
636 | GetViewData().SetSyntaxMode( bSet ); | ||||||||
637 | PaintGrid(); | ||||||||
638 | rBindings.Invalidate( FID_TOGGLESYNTAX((((((26000 + 200) + 20)) + 20)) + 5) ); | ||||||||
639 | rReq.AppendItem( SfxBoolItem( nSlot, bSet ) ); | ||||||||
640 | rReq.Done(); | ||||||||
641 | } | ||||||||
642 | break; | ||||||||
643 | case FID_TOGGLEHEADERS((((((26000 + 200) + 20)) + 20)) + 2): | ||||||||
644 | { | ||||||||
645 | bool bSet = !GetViewData().IsHeaderMode(); | ||||||||
646 | const SfxPoolItem* pItem; | ||||||||
647 | if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET ) | ||||||||
648 | bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | ||||||||
649 | GetViewData().SetHeaderMode( bSet ); | ||||||||
650 | RepeatResize(); | ||||||||
651 | rBindings.Invalidate( FID_TOGGLEHEADERS((((((26000 + 200) + 20)) + 20)) + 2) ); | ||||||||
652 | rReq.AppendItem( SfxBoolItem( nSlot, bSet ) ); | ||||||||
653 | rReq.Done(); | ||||||||
654 | } | ||||||||
655 | break; | ||||||||
656 | |||||||||
657 | case FID_TOGGLEFORMULA((((((26000 + 200) + 20)) + 20)) + 10): | ||||||||
658 | { | ||||||||
659 | ScViewData& rViewData = GetViewData(); | ||||||||
660 | const ScViewOptions& rOpts = rViewData.GetOptions(); | ||||||||
661 | bool bFormulaMode = !rOpts.GetOption( VOPT_FORMULAS ); | ||||||||
662 | const SfxPoolItem *pItem; | ||||||||
663 | if( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET ) | ||||||||
664 | bFormulaMode = static_cast<const SfxBoolItem *>(pItem)->GetValue(); | ||||||||
665 | |||||||||
666 | ScViewOptions aSetOpts = rOpts; | ||||||||
667 | aSetOpts.SetOption( VOPT_FORMULAS, bFormulaMode ); | ||||||||
668 | rViewData.SetOptions( aSetOpts ); | ||||||||
669 | |||||||||
670 | rViewData.GetDocShell()->PostPaintGridAll(); | ||||||||
671 | |||||||||
672 | rBindings.Invalidate( FID_TOGGLEFORMULA((((((26000 + 200) + 20)) + 20)) + 10) ); | ||||||||
673 | rReq.AppendItem( SfxBoolItem( nSlot, bFormulaMode ) ); | ||||||||
674 | rReq.Done(); | ||||||||
675 | } | ||||||||
676 | break; | ||||||||
677 | |||||||||
678 | case FID_TOGGLEINPUTLINE((((((26000 + 200) + 20)) + 20)) + 1): | ||||||||
679 | { | ||||||||
680 | sal_uInt16 nId = ScInputWindowWrapper::GetChildWindowId(); | ||||||||
681 | SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId ); | ||||||||
682 | bool bSet = ( pWnd == nullptr ); | ||||||||
683 | const SfxPoolItem* pItem; | ||||||||
684 | if ( pReqArgs && pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET ) | ||||||||
685 | bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | ||||||||
686 | |||||||||
687 | pThisFrame->SetChildWindow( nId, bSet ); | ||||||||
688 | rBindings.Invalidate( FID_TOGGLEINPUTLINE((((((26000 + 200) + 20)) + 20)) + 1) ); | ||||||||
689 | rReq.AppendItem( SfxBoolItem( nSlot, bSet ) ); | ||||||||
690 | rReq.Done(); | ||||||||
691 | } | ||||||||
692 | break; | ||||||||
693 | |||||||||
694 | case SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0): // status row | ||||||||
695 | case FID_SCALE((((((26000 + 200) + 20)) + 20)) + 4): | ||||||||
696 | { | ||||||||
697 | bool bSyncZoom = SC_MOD()( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule ::Calc)) )->GetAppOptions().GetSynchronizeZoom(); | ||||||||
698 | SvxZoomType eOldZoomType = GetZoomType(); | ||||||||
699 | SvxZoomType eNewZoomType = eOldZoomType; | ||||||||
700 | const Fraction& rOldY = GetViewData().GetZoomY(); // Y is shown | ||||||||
701 | sal_uInt16 nOldZoom = static_cast<sal_uInt16>(long( rOldY * 100 )); | ||||||||
702 | sal_uInt16 nZoom = nOldZoom; | ||||||||
703 | bool bCancel = false; | ||||||||
704 | |||||||||
705 | if ( pReqArgs ) | ||||||||
706 | { | ||||||||
707 | const SvxZoomItem& rZoomItem = pReqArgs->Get(SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0)); | ||||||||
708 | |||||||||
709 | eNewZoomType = rZoomItem.GetType(); | ||||||||
710 | nZoom = rZoomItem.GetValue(); | ||||||||
711 | } | ||||||||
712 | else | ||||||||
713 | { | ||||||||
714 | SfxItemSet aSet ( GetPool(), svl::Items<SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0), SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0)>{} ); | ||||||||
715 | SvxZoomItem aZoomItem( eOldZoomType, nOldZoom, SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0) ); | ||||||||
716 | ScopedVclPtr<AbstractSvxZoomDialog> pDlg; | ||||||||
717 | ScMarkData& rMark = GetViewData().GetMarkData(); | ||||||||
718 | SvxZoomEnableFlags nBtnFlags = SvxZoomEnableFlags::N50 | ||||||||
719 | | SvxZoomEnableFlags::N75 | ||||||||
720 | | SvxZoomEnableFlags::N100 | ||||||||
721 | | SvxZoomEnableFlags::N150 | ||||||||
722 | | SvxZoomEnableFlags::N200 | ||||||||
723 | | SvxZoomEnableFlags::WHOLEPAGE | ||||||||
724 | | SvxZoomEnableFlags::PAGEWIDTH; | ||||||||
725 | |||||||||
726 | if ( rMark.IsMarked() || rMark.IsMultiMarked() ) | ||||||||
727 | nBtnFlags = nBtnFlags | SvxZoomEnableFlags::OPTIMAL; | ||||||||
728 | |||||||||
729 | aZoomItem.SetValueSet( nBtnFlags ); | ||||||||
730 | aSet.Put( aZoomItem ); | ||||||||
731 | SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); | ||||||||
732 | pDlg.disposeAndReset(pFact->CreateSvxZoomDialog(GetFrameWeld(), aSet)); | ||||||||
733 | pDlg->SetLimits( MINZOOM20, MAXZOOM400 ); | ||||||||
734 | |||||||||
735 | bCancel = ( RET_CANCEL == pDlg->Execute() ); | ||||||||
736 | |||||||||
737 | // bCancel is True only if we were in the previous if block, | ||||||||
738 | // so no need to check again pDlg | ||||||||
739 | if ( !bCancel ) | ||||||||
740 | { | ||||||||
741 | const SvxZoomItem& rZoomItem = pDlg->GetOutputItemSet()-> | ||||||||
742 | Get( SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0) ); | ||||||||
743 | |||||||||
744 | eNewZoomType = rZoomItem.GetType(); | ||||||||
745 | nZoom = rZoomItem.GetValue(); | ||||||||
746 | } | ||||||||
747 | } | ||||||||
748 | |||||||||
749 | if ( !bCancel ) | ||||||||
750 | { | ||||||||
751 | if ( eNewZoomType == SvxZoomType::PERCENT ) | ||||||||
752 | { | ||||||||
753 | if ( nZoom < MINZOOM20 ) nZoom = MINZOOM20; | ||||||||
754 | if ( nZoom > MAXZOOM400 ) nZoom = MAXZOOM400; | ||||||||
755 | } | ||||||||
756 | else | ||||||||
757 | { | ||||||||
758 | nZoom = CalcZoom( eNewZoomType, nOldZoom ); | ||||||||
759 | bCancel = nZoom == 0; | ||||||||
760 | } | ||||||||
761 | |||||||||
762 | switch ( eNewZoomType ) | ||||||||
763 | { | ||||||||
764 | case SvxZoomType::WHOLEPAGE: | ||||||||
765 | case SvxZoomType::PAGEWIDTH: | ||||||||
766 | SetZoomType( eNewZoomType, bSyncZoom ); | ||||||||
767 | break; | ||||||||
768 | |||||||||
769 | default: | ||||||||
770 | SetZoomType( SvxZoomType::PERCENT, bSyncZoom ); | ||||||||
771 | } | ||||||||
772 | } | ||||||||
773 | |||||||||
774 | if ( nZoom != nOldZoom && !bCancel ) | ||||||||
775 | { | ||||||||
776 | if (!GetViewData().IsPagebreakMode()) | ||||||||
777 | { | ||||||||
778 | ScAppOptions aNewOpt = pScMod->GetAppOptions(); | ||||||||
779 | aNewOpt.SetZoom( nZoom ); | ||||||||
780 | aNewOpt.SetZoomType( GetZoomType() ); | ||||||||
781 | pScMod->SetAppOptions( aNewOpt ); | ||||||||
782 | } | ||||||||
783 | Fraction aFract( nZoom, 100 ); | ||||||||
784 | SetZoom( aFract, aFract, bSyncZoom ); | ||||||||
785 | PaintGrid(); | ||||||||
786 | PaintTop(); | ||||||||
787 | PaintLeft(); | ||||||||
788 | rBindings.Invalidate( SID_ATTR_ZOOMTypedWhichId<SvxZoomItem>(10000 + 0) ); | ||||||||
789 | rReq.AppendItem( SvxZoomItem( GetZoomType(), nZoom, nSlot ) ); | ||||||||
790 | rReq.Done(); | ||||||||
791 | } | ||||||||
792 | } | ||||||||
793 | break; | ||||||||
794 | |||||||||
795 | case SID_ATTR_ZOOMSLIDER( 10000 + 1065 ): | ||||||||
796 | { | ||||||||
797 | const SfxPoolItem* pItem = nullptr; | ||||||||
798 | bool bSyncZoom = SC_MOD()( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule ::Calc)) )->GetAppOptions().GetSynchronizeZoom(); | ||||||||
799 | if ( pReqArgs && pReqArgs->GetItemState(SID_ATTR_ZOOMSLIDER( 10000 + 1065 ), true, &pItem) == SfxItemState::SET ) | ||||||||
800 | { | ||||||||
801 | const sal_uInt16 nCurrentZoom = static_cast<const SvxZoomSliderItem *>(pItem)->GetValue(); | ||||||||
802 | if( nCurrentZoom ) | ||||||||
803 | { | ||||||||
804 | SetZoomType( SvxZoomType::PERCENT, bSyncZoom ); | ||||||||
805 | if (!GetViewData().IsPagebreakMode()) | ||||||||
806 | { | ||||||||
807 | ScAppOptions aNewOpt = pScMod->GetAppOptions(); | ||||||||
808 | aNewOpt.SetZoom( nCurrentZoom ); | ||||||||
809 | collectUIInformation(OUString::number(nCurrentZoom)); | ||||||||
810 | aNewOpt.SetZoomType( GetZoomType() ); | ||||||||
811 | pScMod->SetAppOptions( aNewOpt ); | ||||||||
812 | } | ||||||||
813 | Fraction aFract( nCurrentZoom,100 ); | ||||||||
814 | SetZoom( aFract, aFract, bSyncZoom ); | ||||||||
815 | PaintGrid(); | ||||||||
816 | PaintTop(); | ||||||||
817 | PaintLeft(); | ||||||||
818 | rBindings.Invalidate( SID_ATTR_ZOOMSLIDER( 10000 + 1065 ) ); | ||||||||
819 | rReq.Done(); | ||||||||
820 | } | ||||||||
821 | } | ||||||||
822 | } | ||||||||
823 | break; | ||||||||
824 | |||||||||
825 | case FID_TAB_SELECTALL((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22 )) + 20)) + 29))+3): | ||||||||
826 | SelectAllTables(); | ||||||||
827 | rReq.Done(); | ||||||||
828 | break; | ||||||||
829 | |||||||||
830 | case FID_TAB_DESELECTALL((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22 )) + 20)) + 29))+7): | ||||||||
831 | DeselectAllTables(); | ||||||||
832 | rReq.Done(); | ||||||||
833 | break; | ||||||||
834 | |||||||||
835 | case SID_SELECT_TABLES((26000) + 90): | ||||||||
836 | { | ||||||||
837 | ScViewData& rViewData = GetViewData(); | ||||||||
838 | ScDocument& rDoc = rViewData.GetDocument(); | ||||||||
839 | ScMarkData& rMark = rViewData.GetMarkData(); | ||||||||
840 | SCTAB nTabCount = rDoc.GetTableCount(); | ||||||||
841 | SCTAB nTab; | ||||||||
842 | |||||||||
843 | ::std::vector < sal_Int32 > aIndexList; | ||||||||
844 | const SfxIntegerListItem* pItem = rReq.GetArg<SfxIntegerListItem>(SID_SELECT_TABLES((26000) + 90)); | ||||||||
845 | if ( pItem
| ||||||||
846 | aIndexList = pItem->GetList(); | ||||||||
847 | else | ||||||||
848 | { | ||||||||
849 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | ||||||||
850 | |||||||||
851 | ScopedVclPtr<AbstractScShowTabDlg> pDlg(pFact->CreateScShowTabDlg(GetFrameWeld())); | ||||||||
852 | pDlg->SetDescription( | ||||||||
853 | ScResId( STR_DLG_SELECTTABLES_TITLEreinterpret_cast<char const *>("STR_DLG_SELECTTABLES_TITLE" "\004" u8"Select Sheets") ), | ||||||||
854 | ScResId( STR_DLG_SELECTTABLES_LBNAMEreinterpret_cast<char const *>("STR_DLG_SELECTTABLES_LBNAME" "\004" u8"~Selected sheets") ), | ||||||||
855 | GetStaticInterface()->GetSlot(SID_SELECT_TABLES((26000) + 90))->GetCommand(), HID_SELECTTABLES"SC_HID_SELECTTABLES" ); | ||||||||
856 | |||||||||
857 | // fill all table names with selection state | ||||||||
858 | OUString aTabName; | ||||||||
859 | for( nTab = 0; nTab < nTabCount; ++nTab ) | ||||||||
860 | { | ||||||||
861 | rDoc.GetName( nTab, aTabName ); | ||||||||
862 | pDlg->Insert( aTabName, rMark.GetTableSelect( nTab ) ); | ||||||||
863 | } | ||||||||
864 | |||||||||
865 | if( pDlg->Execute() == RET_OK ) | ||||||||
866 | { | ||||||||
867 | aIndexList = pDlg->GetSelectedRows(); | ||||||||
868 | pDlg.disposeAndClear(); | ||||||||
869 | rReq.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES((26000) + 90), aIndexList ) ); | ||||||||
870 | } | ||||||||
871 | else | ||||||||
872 | rReq.Ignore(); | ||||||||
873 | } | ||||||||
874 | |||||||||
875 | if ( !aIndexList.empty() ) | ||||||||
876 | { | ||||||||
877 | sal_uInt16 nSelCount = aIndexList.size(); | ||||||||
878 | sal_uInt16 nSelIx; | ||||||||
879 | SCTAB nFirstVisTab = 0; | ||||||||
880 | |||||||||
881 | // special case: only hidden tables selected -> do nothing | ||||||||
882 | bool bVisSelected = false; | ||||||||
883 | for( nSelIx = 0; !bVisSelected && (nSelIx < nSelCount); ++nSelIx ) | ||||||||
884 | { | ||||||||
885 | nFirstVisTab = static_cast<SCTAB>(aIndexList[nSelIx]); | ||||||||
886 | bVisSelected = rDoc.IsVisible( nFirstVisTab ); | ||||||||
887 | } | ||||||||
888 | if( !bVisSelected ) | ||||||||
889 | nSelCount = 0; | ||||||||
890 | |||||||||
891 | // select the tables | ||||||||
892 | if( nSelCount ) | ||||||||
893 | { | ||||||||
894 | for( nTab = 0; nTab < nTabCount; ++nTab ) | ||||||||
895 | rMark.SelectTable( nTab, false ); | ||||||||
896 | |||||||||
897 | for( nSelIx = 0; nSelIx < nSelCount; ++nSelIx ) | ||||||||
898 | rMark.SelectTable( static_cast<SCTAB>(aIndexList[nSelIx]), true ); | ||||||||
899 | |||||||||
900 | // activate another table, if current is deselected | ||||||||
901 | if( !rMark.GetTableSelect( rViewData.GetTabNo() ) ) | ||||||||
902 | { | ||||||||
903 | rMark.SelectTable( nFirstVisTab, true ); | ||||||||
904 | SetTabNo( nFirstVisTab ); | ||||||||
905 | } | ||||||||
906 | |||||||||
907 | rViewData.GetDocShell()->PostPaintExtras(); | ||||||||
908 | SfxBindings& rBind = rViewData.GetBindings(); | ||||||||
909 | rBind.Invalidate( FID_FILL_TAB((((26000 + 200) + 20)) + 8) ); | ||||||||
910 | rBind.Invalidate( FID_TAB_DESELECTALL((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22 )) + 20)) + 29))+7) ); | ||||||||
911 | } | ||||||||
912 | |||||||||
913 | rReq.Done(); | ||||||||
914 | } | ||||||||
915 | } | ||||||||
916 | break; | ||||||||
917 | |||||||||
918 | case SID_OUTLINE_DELETEALL( 10000 + 234 ): | ||||||||
919 | RemoveAllOutlines(); | ||||||||
920 | rReq.Done(); | ||||||||
921 | break; | ||||||||
922 | |||||||||
923 | case SID_AUTO_OUTLINE((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 14): | ||||||||
924 | AutoOutline(); | ||||||||
925 | rReq.Done(); | ||||||||
926 | break; | ||||||||
927 | |||||||||
928 | case SID_WINDOW_SPLIT((26000) + 69): | ||||||||
929 | { | ||||||||
930 | ScSplitMode eHSplit = GetViewData().GetHSplitMode(); | ||||||||
931 | ScSplitMode eVSplit = GetViewData().GetVSplitMode(); | ||||||||
932 | if ( eHSplit == SC_SPLIT_NORMAL || eVSplit == SC_SPLIT_NORMAL ) // remove | ||||||||
933 | RemoveSplit(); | ||||||||
934 | else if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX ) // normal | ||||||||
935 | FreezeSplitters( false ); | ||||||||
936 | else // create | ||||||||
937 | SplitAtCursor(); | ||||||||
938 | rReq.Done(); | ||||||||
939 | |||||||||
940 | InvalidateSplit(); | ||||||||
941 | } | ||||||||
942 | break; | ||||||||
943 | |||||||||
944 | case SID_WINDOW_FIX((26000) + 70): | ||||||||
945 | { | ||||||||
946 | if (!comphelper::LibreOfficeKit::isActive()) | ||||||||
947 | { | ||||||||
948 | ScSplitMode eHSplit = GetViewData().GetHSplitMode(); | ||||||||
949 | ScSplitMode eVSplit = GetViewData().GetVSplitMode(); | ||||||||
950 | if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX ) // remove | ||||||||
951 | RemoveSplit(); | ||||||||
952 | else | ||||||||
953 | FreezeSplitters( true, SC_SPLIT_METHOD_CURSOR); // create or fixate | ||||||||
954 | rReq.Done(); | ||||||||
955 | InvalidateSplit(); | ||||||||
956 | } | ||||||||
957 | else | ||||||||
958 | { | ||||||||
959 | ScViewData& rViewData = GetViewData(); | ||||||||
960 | SCTAB nThisTab = rViewData.GetTabNo(); | ||||||||
961 | bool bChangedX = false, bChangedY = false; | ||||||||
962 | if (rViewData.GetLOKSheetFreezeIndex(true) > 0 || | ||||||||
963 | rViewData.GetLOKSheetFreezeIndex(false) > 0 ) // remove freeze | ||||||||
964 | { | ||||||||
965 | bChangedX = rViewData.RemoveLOKFreeze(); | ||||||||
966 | } // create or fixate | ||||||||
967 | else | ||||||||
968 | { | ||||||||
969 | bChangedX = rViewData.SetLOKSheetFreezeIndex(rViewData.GetCurX(), true); // Freeze column | ||||||||
970 | bChangedY = rViewData.SetLOKSheetFreezeIndex(rViewData.GetCurY(), false); // Freeze row | ||||||||
971 | } | ||||||||
972 | |||||||||
973 | rReq.Done(); | ||||||||
974 | if (bChangedX || bChangedY) | ||||||||
975 | { | ||||||||
976 | rBindings.Invalidate( SID_WINDOW_FIX((26000) + 70) ); | ||||||||
977 | rBindings.Invalidate( SID_WINDOW_FIX_COL((26000 + 100) + 85) ); | ||||||||
978 | rBindings.Invalidate( SID_WINDOW_FIX_ROW((26000 + 100) + 84) ); | ||||||||
979 | // Invalidate the slot for all views on the same tab of the document. | ||||||||
980 | SfxLokHelper::forEachOtherView(this, [nThisTab](ScTabViewShell* pOther) { | ||||||||
981 | ScViewData& rOtherViewData = pOther->GetViewData(); | ||||||||
982 | if (rOtherViewData.GetTabNo() != nThisTab) | ||||||||
983 | return; | ||||||||
984 | |||||||||
985 | SfxBindings& rOtherBind = rOtherViewData.GetBindings(); | ||||||||
986 | rOtherBind.Invalidate( SID_WINDOW_FIX((26000) + 70) ); | ||||||||
987 | rOtherBind.Invalidate( SID_WINDOW_FIX_COL((26000 + 100) + 85) ); | ||||||||
988 | rOtherBind.Invalidate( SID_WINDOW_FIX_ROW((26000 + 100) + 84) ); | ||||||||
989 | }); | ||||||||
990 | } | ||||||||
991 | } | ||||||||
992 | } | ||||||||
993 | break; | ||||||||
994 | |||||||||
995 | case SID_WINDOW_FIX_COL((26000 + 100) + 85): | ||||||||
996 | case SID_WINDOW_FIX_ROW((26000 + 100) + 84): | ||||||||
997 | { | ||||||||
998 | bool bIsCol = (nSlot == SID_WINDOW_FIX_COL((26000 + 100) + 85)); | ||||||||
999 | sal_Int32 nFreezeIndex = 1; | ||||||||
1000 | if (const SfxInt32Item* pItem = rReq.GetArg<SfxInt32Item>(nSlot)) | ||||||||
1001 | { | ||||||||
1002 | nFreezeIndex = pItem->GetValue(); | ||||||||
1003 | if (nFreezeIndex < 0) | ||||||||
1004 | nFreezeIndex = 0; | ||||||||
1005 | } | ||||||||
1006 | |||||||||
1007 | if (comphelper::LibreOfficeKit::isActive()) | ||||||||
1008 | { | ||||||||
1009 | ScViewData& rViewData = GetViewData(); | ||||||||
1010 | SCTAB nThisTab = rViewData.GetTabNo(); | ||||||||
1011 | bool bChanged = rViewData.SetLOKSheetFreezeIndex(nFreezeIndex, bIsCol); | ||||||||
1012 | rReq.Done(); | ||||||||
1013 | if (bChanged) | ||||||||
1014 | { | ||||||||
1015 | rBindings.Invalidate( SID_WINDOW_FIX((26000) + 70) ); | ||||||||
1016 | rBindings.Invalidate(nSlot); | ||||||||
1017 | // Invalidate the slot for all views on the same tab of the document. | ||||||||
1018 | SfxLokHelper::forEachOtherView(this, [nSlot, nThisTab](ScTabViewShell* pOther) { | ||||||||
1019 | ScViewData& rOtherViewData = pOther->GetViewData(); | ||||||||
1020 | if (rOtherViewData.GetTabNo() != nThisTab) | ||||||||
1021 | return; | ||||||||
1022 | |||||||||
1023 | SfxBindings& rOtherBind = rOtherViewData.GetBindings(); | ||||||||
1024 | rOtherBind.Invalidate( SID_WINDOW_FIX((26000) + 70) ); | ||||||||
1025 | rOtherBind.Invalidate(nSlot); | ||||||||
1026 | }); | ||||||||
1027 | } | ||||||||
1028 | } | ||||||||
1029 | else | ||||||||
1030 | { | ||||||||
1031 | FreezeSplitters( true, bIsCol ? SC_SPLIT_METHOD_COL : SC_SPLIT_METHOD_ROW, nFreezeIndex); | ||||||||
1032 | rReq.Done(); | ||||||||
1033 | InvalidateSplit(); | ||||||||
1034 | } | ||||||||
1035 | } | ||||||||
1036 | break; | ||||||||
1037 | |||||||||
1038 | case FID_CHG_SHOW((((26000 + 200) + 20)) + 19): | ||||||||
1039 | { | ||||||||
1040 | sal_uInt16 nId = ScHighlightChgDlgWrapper::GetChildWindowId(); | ||||||||
1041 | SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId ); | ||||||||
1042 | |||||||||
1043 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | ||||||||
1044 | } | ||||||||
1045 | break; | ||||||||
1046 | |||||||||
1047 | case FID_CHG_ACCEPT((((((26000 + 200) + 20)) + 20)) + 18): | ||||||||
1048 | { | ||||||||
1049 | pThisFrame->ToggleChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId()); | ||||||||
1050 | GetViewFrame()->GetBindings().Invalidate(FID_CHG_ACCEPT((((((26000 + 200) + 20)) + 20)) + 18)); | ||||||||
1051 | rReq.Done (); | ||||||||
1052 | |||||||||
1053 | /* | ||||||||
1054 | sal_uInt16 nId = ScAcceptChgDlgWrapper::GetChildWindowId(); | ||||||||
1055 | SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId ); | ||||||||
1056 | |||||||||
1057 | pScMod->SetRefDialog( nId, pWnd ? sal_False : sal_True ); | ||||||||
1058 | */ | ||||||||
1059 | } | ||||||||
1060 | break; | ||||||||
1061 | |||||||||
1062 | case FID_CHG_COMMENT((((((26000 + 200) + 20)) + 20)) + 19): | ||||||||
1063 | { | ||||||||
1064 | ScViewData& rData = GetViewData(); | ||||||||
1065 | ScAddress aCursorPos( rData.GetCurX(), rData.GetCurY(), rData.GetTabNo() ); | ||||||||
1066 | ScDocShell* pDocSh = rData.GetDocShell(); | ||||||||
1067 | |||||||||
1068 | ScChangeAction* pAction = pDocSh->GetChangeAction( aCursorPos ); | ||||||||
1069 | if ( pAction ) | ||||||||
1070 | { | ||||||||
1071 | const SfxPoolItem* pItem; | ||||||||
1072 | if ( pReqArgs && | ||||||||
1073 | pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET && | ||||||||
1074 | dynamic_cast<const SfxStringItem*>( pItem) != nullptr ) | ||||||||
1075 | { | ||||||||
1076 | OUString aComment = static_cast<const SfxStringItem*>(pItem)->GetValue(); | ||||||||
1077 | pDocSh->SetChangeComment( pAction, aComment ); | ||||||||
1078 | rReq.Done(); | ||||||||
1079 | } | ||||||||
1080 | else | ||||||||
1081 | { | ||||||||
1082 | pDocSh->ExecuteChangeCommentDialog(pAction, GetFrameWeld()); | ||||||||
1083 | rReq.Done(); | ||||||||
1084 | } | ||||||||
1085 | } | ||||||||
1086 | } | ||||||||
1087 | break; | ||||||||
1088 | |||||||||
1089 | case SID_CREATE_SW_DRAWVIEW( 10000 + 860 ): | ||||||||
1090 | // is called by Forms, when the DrawView has to be created with all | ||||||||
1091 | // the extras | ||||||||
1092 | if (!GetScDrawView()) | ||||||||
1093 | { | ||||||||
1094 | GetViewData().GetDocShell()->MakeDrawLayer(); | ||||||||
1095 | rBindings.InvalidateAll(false); | ||||||||
1096 | } | ||||||||
1097 | break; | ||||||||
1098 | |||||||||
1099 | case FID_PROTECT_DOC((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 7): | ||||||||
1100 | { | ||||||||
1101 | ScDocument& rDoc = GetViewData().GetDocument(); | ||||||||
1102 | |||||||||
1103 | if( pReqArgs ) | ||||||||
1104 | { | ||||||||
1105 | const SfxPoolItem* pItem; | ||||||||
1106 | if( pReqArgs->HasItem( FID_PROTECT_DOC((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 7), &pItem ) && | ||||||||
1107 | static_cast<const SfxBoolItem*>(pItem)->GetValue() == rDoc.IsDocProtected() ) | ||||||||
1108 | { | ||||||||
1109 | rReq.Ignore(); | ||||||||
1110 | break; | ||||||||
1111 | } | ||||||||
1112 | } | ||||||||
1113 | |||||||||
1114 | ScDocProtection* pProtect = rDoc.GetDocProtection(); | ||||||||
1115 | if (pProtect && pProtect->isProtected()) | ||||||||
1116 | { | ||||||||
1117 | bool bCancel = false; | ||||||||
1118 | OUString aPassword; | ||||||||
1119 | |||||||||
1120 | if (pProtect->isProtectedWithPass()) | ||||||||
1121 | { | ||||||||
1122 | OUString aText(ScResId(SCSTR_PASSWORDreinterpret_cast<char const *>("SCSTR_PASSWORD" "\004" u8"Password:" ))); | ||||||||
1123 | |||||||||
1124 | SfxPasswordDialog aDlg(GetFrameWeld(), &aText); | ||||||||
1125 | aDlg.set_title(ScResId(SCSTR_UNPROTECTDOCreinterpret_cast<char const *>("SCSTR_UNPROTECTDOC" "\004" u8"Unprotect Spreadsheet Structure"))); | ||||||||
1126 | aDlg.SetMinLen(0); | ||||||||
1127 | aDlg.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_DOC((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 7))->GetCommand()); | ||||||||
1128 | aDlg.SetEditHelpId(HID_PASSWD_DOC"SC_HID_PASSWD_DOC"); | ||||||||
1129 | |||||||||
1130 | if (aDlg.run() == RET_OK) | ||||||||
1131 | aPassword = aDlg.GetPassword(); | ||||||||
1132 | else | ||||||||
1133 | bCancel = true; | ||||||||
1134 | } | ||||||||
1135 | if (!bCancel) | ||||||||
1136 | { | ||||||||
1137 | Unprotect( TABLEID_DOC, aPassword ); | ||||||||
1138 | rReq.AppendItem( SfxBoolItem( FID_PROTECT_DOC((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 7), false ) ); | ||||||||
1139 | rReq.Done(); | ||||||||
1140 | } | ||||||||
1141 | } | ||||||||
1142 | else | ||||||||
1143 | { | ||||||||
1144 | OUString aText(ScResId(SCSTR_PASSWORDOPTreinterpret_cast<char const *>("SCSTR_PASSWORDOPT" "\004" u8"Password (optional):"))); | ||||||||
1145 | |||||||||
1146 | SfxPasswordDialog aDlg(GetFrameWeld(), &aText); | ||||||||
1147 | aDlg.set_title(ScResId(SCSTR_PROTECTDOCreinterpret_cast<char const *>("SCSTR_PROTECTDOC" "\004" u8"Protect Spreadsheet Structure"))); | ||||||||
1148 | aDlg.SetMinLen( 0 ); | ||||||||
1149 | aDlg.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_DOC((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 7))->GetCommand()); | ||||||||
1150 | aDlg.SetEditHelpId(HID_PASSWD_DOC"SC_HID_PASSWD_DOC"); | ||||||||
1151 | aDlg.ShowExtras(SfxShowExtras::CONFIRM); | ||||||||
1152 | aDlg.SetConfirmHelpId(HID_PASSWD_DOC_CONFIRM"SC_HID_PASSWD_DOC_CONFIRM"); | ||||||||
1153 | |||||||||
1154 | if (aDlg.run() == RET_OK) | ||||||||
1155 | { | ||||||||
1156 | OUString aPassword = aDlg.GetPassword(); | ||||||||
1157 | Protect( TABLEID_DOC, aPassword ); | ||||||||
1158 | rReq.AppendItem( SfxBoolItem( FID_PROTECT_DOC((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 7), true ) ); | ||||||||
1159 | rReq.Done(); | ||||||||
1160 | } | ||||||||
1161 | } | ||||||||
1162 | rBindings.Invalidate( FID_PROTECT_DOC((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 7) ); | ||||||||
1163 | } | ||||||||
1164 | break; | ||||||||
1165 | |||||||||
1166 | case FID_PROTECT_TABLE((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 6): | ||||||||
1167 | { | ||||||||
1168 | ScDocument& rDoc = GetViewData().GetDocument(); | ||||||||
1169 | SCTAB nTab = GetViewData().GetTabNo(); | ||||||||
1170 | bool bOldProtection = rDoc.IsTabProtected(nTab); | ||||||||
1171 | |||||||||
1172 | if( pReqArgs ) | ||||||||
1173 | { | ||||||||
1174 | const SfxPoolItem* pItem; | ||||||||
1175 | bool bNewProtection = !bOldProtection; | ||||||||
1176 | if( pReqArgs->HasItem( FID_PROTECT_TABLE((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 6), &pItem ) ) | ||||||||
1177 | bNewProtection = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | ||||||||
1178 | if( bNewProtection == bOldProtection ) | ||||||||
1179 | { | ||||||||
1180 | rReq.Ignore(); | ||||||||
1181 | break; | ||||||||
1182 | } | ||||||||
1183 | } | ||||||||
1184 | |||||||||
1185 | if (bOldProtection) | ||||||||
1186 | { | ||||||||
1187 | // Unprotect a protected sheet. | ||||||||
1188 | |||||||||
1189 | ScTableProtection* pProtect = rDoc.GetTabProtection(nTab); | ||||||||
1190 | if (pProtect && pProtect->isProtectedWithPass()) | ||||||||
1191 | { | ||||||||
1192 | OUString aText( ScResId(SCSTR_PASSWORDOPTreinterpret_cast<char const *>("SCSTR_PASSWORDOPT" "\004" u8"Password (optional):")) ); | ||||||||
1193 | SfxPasswordDialog aDlg(GetFrameWeld(), &aText); | ||||||||
1194 | aDlg.set_title(ScResId(SCSTR_UNPROTECTTABreinterpret_cast<char const *>("SCSTR_UNPROTECTTAB" "\004" u8"Unprotect Sheet"))); | ||||||||
1195 | aDlg.SetMinLen(0); | ||||||||
1196 | aDlg.set_help_id(GetStaticInterface()->GetSlot(FID_PROTECT_TABLE((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 6))->GetCommand()); | ||||||||
1197 | aDlg.SetEditHelpId(HID_PASSWD_TABLE"SC_HID_PASSWD_TABLE"); | ||||||||
1198 | |||||||||
1199 | if (aDlg.run() == RET_OK) | ||||||||
1200 | { | ||||||||
1201 | OUString aPassword = aDlg.GetPassword(); | ||||||||
1202 | Unprotect(nTab, aPassword); | ||||||||
1203 | } | ||||||||
1204 | } | ||||||||
1205 | else | ||||||||
1206 | // this sheet is not password-protected. | ||||||||
1207 | Unprotect(nTab, OUString()); | ||||||||
1208 | |||||||||
1209 | if (!pReqArgs) | ||||||||
1210 | { | ||||||||
1211 | rReq.AppendItem( SfxBoolItem(FID_PROTECT_TABLE((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 6), false) ); | ||||||||
1212 | rReq.Done(); | ||||||||
1213 | } | ||||||||
1214 | } | ||||||||
1215 | else | ||||||||
1216 | { | ||||||||
1217 | // Protect a current sheet. | ||||||||
1218 | |||||||||
1219 | ScTableProtectionDlg aDlg(GetFrameWeld()); | ||||||||
1220 | |||||||||
1221 | ScTableProtection* pProtect = rDoc.GetTabProtection(nTab); | ||||||||
1222 | if (pProtect) | ||||||||
1223 | aDlg.SetDialogData(*pProtect); | ||||||||
1224 | |||||||||
1225 | if (aDlg.run() == RET_OK) | ||||||||
1226 | { | ||||||||
1227 | pScMod->InputEnterHandler(); | ||||||||
1228 | |||||||||
1229 | ScTableProtection aNewProtect; | ||||||||
1230 | aDlg.WriteData(aNewProtect); | ||||||||
1231 | ProtectSheet(nTab, aNewProtect); | ||||||||
1232 | if (!pReqArgs) | ||||||||
1233 | { | ||||||||
1234 | rReq.AppendItem( SfxBoolItem(FID_PROTECT_TABLE((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 6), true) ); | ||||||||
1235 | rReq.Done(); | ||||||||
1236 | } | ||||||||
1237 | } | ||||||||
1238 | } | ||||||||
1239 | TabChanged(); | ||||||||
1240 | UpdateInputHandler(true); // to immediately enable input again | ||||||||
1241 | SelectionChanged(); | ||||||||
1242 | } | ||||||||
1243 | break; | ||||||||
1244 | |||||||||
1245 | case SID_OPT_LOCALE_CHANGED(((((10000 + 1499) + 1) + 499) + 1) + 94) : | ||||||||
1246 | { // locale changed, SYSTEM number formats changed => repaint cell contents | ||||||||
1247 | PaintGrid(); | ||||||||
1248 | rReq.Done(); | ||||||||
1249 | } | ||||||||
1250 | break; | ||||||||
1251 | |||||||||
1252 | default: | ||||||||
1253 | OSL_FAIL("Unknown Slot at ScTabViewShell::Execute")do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sc/source/ui/view/tabvwsh3.cxx" ":" "1253" ": "), "%s", "Unknown Slot at ScTabViewShell::Execute" ); } } while (false); | ||||||||
1254 | break; | ||||||||
1255 | } | ||||||||
1256 | } | ||||||||
1257 | |||||||||
1258 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | /* |
3 | * This file is part of the LibreOffice project. |
4 | * |
5 | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | * |
9 | * This file incorporates work covered by the following license notice: |
10 | * |
11 | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | * contributor license agreements. See the NOTICE file distributed |
13 | * with this work for additional information regarding copyright |
14 | * ownership. The ASF licenses this file to you under the Apache |
15 | * License, Version 2.0 (the "License"); you may not use this file |
16 | * except in compliance with the License. You may obtain a copy of |
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | */ |
19 | |
20 | #ifndef INCLUDED_VCL_PTR_HXX |
21 | #define INCLUDED_VCL_PTR_HXX |
22 | |
23 | #include <sal/config.h> |
24 | |
25 | #include <rtl/ref.hxx> |
26 | |
27 | #include <utility> |
28 | #include <type_traits> |
29 | |
30 | #ifdef DBG_UTIL |
31 | #ifndef _WIN32 |
32 | #include <vcl/vclmain.hxx> |
33 | #endif |
34 | #endif |
35 | |
36 | class VclReferenceBase; |
37 | |
38 | namespace vcl::detail { |
39 | |
40 | template<typename> |
41 | constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; } |
42 | |
43 | template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase( |
44 | int (*)[sizeof(T)]) |
45 | { return std::is_base_of<VclReferenceBase, T>::value; } |
46 | |
47 | } // namespace vcl::detail |
48 | |
49 | /** |
50 | * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses. |
51 | * |
52 | * For more details on the design please see vcl/README.lifecycle |
53 | * |
54 | * @param reference_type must be a subclass of vcl::Window |
55 | */ |
56 | template <class reference_type> |
57 | class VclPtr |
58 | { |
59 | static_assert( |
60 | vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>( |
61 | nullptr), |
62 | "template argument type must be derived from VclReferenceBase"); |
63 | |
64 | ::rtl::Reference<reference_type> m_rInnerRef; |
65 | |
66 | public: |
67 | /** Constructor... |
68 | */ |
69 | VclPtr() |
70 | : m_rInnerRef() |
71 | {} |
72 | |
73 | /** Constructor... |
74 | */ |
75 | VclPtr (reference_type * pBody) |
76 | : m_rInnerRef(pBody) |
77 | {} |
78 | |
79 | /** Constructor... that doesn't take a ref. |
80 | */ |
81 | VclPtr (reference_type * pBody, __sal_NoAcquire) |
82 | : m_rInnerRef(pBody, SAL_NO_ACQUIRE) |
83 | {} |
84 | |
85 | /** Up-casting conversion constructor: Copies interface reference. |
86 | |
87 | Does not work for up-casts to ambiguous bases. For the special case of |
88 | up-casting to Reference< XInterface >, see the corresponding conversion |
89 | operator. |
90 | |
91 | @param rRef another reference |
92 | */ |
93 | template< class derived_type > |
94 | VclPtr( |
95 | const VclPtr< derived_type > & rRef, |
96 | typename std::enable_if< |
97 | std::is_base_of<reference_type, derived_type>::value, int>::type |
98 | = 0 ) |
99 | : m_rInnerRef( static_cast<reference_type*>(rRef) ) |
100 | { |
101 | } |
102 | |
103 | #if defined(DBG_UTIL) && !defined(_WIN32) |
104 | virtual ~VclPtr() |
105 | { |
106 | assert(m_rInnerRef.get() == nullptr || vclmain::isAlive())(static_cast <bool> (m_rInnerRef.get() == nullptr || vclmain ::isAlive()) ? void (0) : __assert_fail ("m_rInnerRef.get() == nullptr || vclmain::isAlive()" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 106, __extension__ __PRETTY_FUNCTION__)); |
107 | // We can be one of the intermediate counts, but if we are the last |
108 | // VclPtr keeping this object alive, then something forgot to call dispose(). |
109 | assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1)(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)) |
110 | && "someone forgot to call dispose()")(static_cast <bool> ((!m_rInnerRef.get() || m_rInnerRef ->isDisposed() || m_rInnerRef->getRefCount() > 1) && "someone forgot to call dispose()") ? void (0) : __assert_fail ("(!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) && \"someone forgot to call dispose()\"" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 110, __extension__ __PRETTY_FUNCTION__)); |
111 | } |
112 | VclPtr(VclPtr const &) = default; |
113 | VclPtr(VclPtr &&) = default; |
114 | VclPtr & operator =(VclPtr const &) = default; |
115 | VclPtr & operator =(VclPtr &&) = default; |
116 | #endif |
117 | |
118 | /** |
119 | * A construction helper for VclPtr. Since VclPtr types are created |
120 | * with a reference-count of one - to help fit into the existing |
121 | * code-flow; this helps us to construct them easily. |
122 | * |
123 | * For more details on the design please see vcl/README.lifecycle |
124 | * |
125 | * @tparam reference_type must be a subclass of vcl::Window |
126 | */ |
127 | template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg) |
128 | { |
129 | return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ); |
130 | } |
131 | |
132 | /** Probably most common used: handle->someBodyOp(). |
133 | */ |
134 | reference_type * operator->() const |
135 | { |
136 | return m_rInnerRef.get(); |
137 | } |
138 | |
139 | /** Get the body. Can be used instead of operator->(). |
140 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() |
141 | are the same. |
142 | */ |
143 | reference_type * get() const |
144 | { |
145 | return m_rInnerRef.get(); |
146 | } |
147 | |
148 | void set(reference_type *pBody) |
149 | { |
150 | m_rInnerRef.set(pBody); |
151 | } |
152 | |
153 | void reset(reference_type *pBody) |
154 | { |
155 | m_rInnerRef.set(pBody); |
156 | } |
157 | |
158 | /** Up-casting copy assignment operator. |
159 | |
160 | Does not work for up-casts to ambiguous bases. |
161 | |
162 | @param rRef another reference |
163 | */ |
164 | template<typename derived_type> |
165 | typename std::enable_if< |
166 | std::is_base_of<reference_type, derived_type>::value, |
167 | VclPtr &>::type |
168 | operator =(VclPtr<derived_type> const & rRef) |
169 | { |
170 | m_rInnerRef.set(rRef.get()); |
171 | return *this; |
172 | } |
173 | |
174 | VclPtr & operator =(reference_type * pBody) |
175 | { |
176 | m_rInnerRef.set(pBody); |
177 | return *this; |
178 | } |
179 | |
180 | operator reference_type * () const |
181 | { |
182 | return m_rInnerRef.get(); |
183 | } |
184 | |
185 | explicit operator bool () const |
186 | { |
187 | return m_rInnerRef.get() != nullptr; |
188 | } |
189 | |
190 | void clear() |
191 | { |
192 | m_rInnerRef.clear(); |
193 | } |
194 | |
195 | void reset() |
196 | { |
197 | m_rInnerRef.clear(); |
198 | } |
199 | |
200 | void disposeAndClear() |
201 | { |
202 | // hold it alive for the lifetime of this method |
203 | ::rtl::Reference<reference_type> aTmp(m_rInnerRef); |
204 | m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-) |
205 | if (aTmp.get()) { |
206 | aTmp->disposeOnce(); |
207 | } |
208 | } |
209 | |
210 | /** Needed to place VclPtr's into STL collection. |
211 | */ |
212 | bool operator< (const VclPtr<reference_type> & handle) const |
213 | { |
214 | return (m_rInnerRef < handle.m_rInnerRef); |
215 | } |
216 | }; // class VclPtr |
217 | |
218 | template<typename T1, typename T2> |
219 | inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
220 | return p1.get() == p2.get(); |
221 | } |
222 | |
223 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2) |
224 | { |
225 | return p1.get() == p2; |
226 | } |
227 | |
228 | template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) { |
229 | return p1.get() == p2; |
230 | } |
231 | |
232 | template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2) |
233 | { |
234 | return p1 == p2.get(); |
235 | } |
236 | |
237 | template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) { |
238 | return p1 == p2.get(); |
239 | } |
240 | |
241 | template<typename T1, typename T2> |
242 | inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { |
243 | return !(p1 == p2); |
244 | } |
245 | |
246 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2) |
247 | { |
248 | return !(p1 == p2); |
249 | } |
250 | |
251 | template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) { |
252 | return !(p1 == p2); |
253 | } |
254 | |
255 | template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2) |
256 | { |
257 | return !(p1 == p2); |
258 | } |
259 | |
260 | template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) { |
261 | return !(p1 == p2); |
262 | } |
263 | |
264 | /** |
265 | * A construction helper for a temporary VclPtr. Since VclPtr types |
266 | * are created with a reference-count of one - to help fit into |
267 | * the existing code-flow; this helps us to construct them easily. |
268 | * see also VclPtr::Create and ScopedVclPtr |
269 | * |
270 | * For more details on the design please see vcl/README.lifecycle |
271 | * |
272 | * @param reference_type must be a subclass of vcl::Window |
273 | */ |
274 | template <class reference_type> |
275 | class SAL_WARN_UNUSED__attribute__((warn_unused)) VclPtrInstance final : public VclPtr<reference_type> |
276 | { |
277 | public: |
278 | template<typename... Arg> VclPtrInstance(Arg &&... arg) |
279 | : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
280 | { |
281 | } |
282 | |
283 | /** |
284 | * Override and disallow this, to prevent people accidentally calling it and actually |
285 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
286 | */ |
287 | template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete; |
288 | }; |
289 | |
290 | template <class reference_type> |
291 | class ScopedVclPtr : public VclPtr<reference_type> |
292 | { |
293 | public: |
294 | /** Constructor... |
295 | */ |
296 | ScopedVclPtr() |
297 | : VclPtr<reference_type>() |
298 | {} |
299 | |
300 | /** Constructor |
301 | */ |
302 | ScopedVclPtr (reference_type * pBody) |
303 | : VclPtr<reference_type>(pBody) |
304 | {} |
305 | |
306 | /** Copy constructor... |
307 | */ |
308 | ScopedVclPtr (const VclPtr<reference_type> & handle) |
309 | : VclPtr<reference_type>(handle) |
310 | {} |
311 | |
312 | /** |
313 | Assignment that releases the last reference. |
314 | */ |
315 | void disposeAndReset(reference_type *pBody) |
316 | { |
317 | if (pBody != this->get()) { |
318 | VclPtr<reference_type>::disposeAndClear(); |
319 | VclPtr<reference_type>::set(pBody); |
320 | } |
321 | } |
322 | |
323 | /** |
324 | Assignment that releases the last reference. |
325 | */ |
326 | ScopedVclPtr<reference_type>& operator = (reference_type * pBody) |
327 | { |
328 | disposeAndReset(pBody); |
329 | return *this; |
330 | } |
331 | |
332 | /** Up-casting conversion constructor: Copies interface reference. |
333 | |
334 | Does not work for up-casts to ambiguous bases. For the special case of |
335 | up-casting to Reference< XInterface >, see the corresponding conversion |
336 | operator. |
337 | |
338 | @param rRef another reference |
339 | */ |
340 | template< class derived_type > |
341 | ScopedVclPtr( |
342 | const VclPtr< derived_type > & rRef, |
343 | typename std::enable_if< |
344 | std::is_base_of<reference_type, derived_type>::value, int>::type |
345 | = 0 ) |
346 | : VclPtr<reference_type>( rRef ) |
347 | { |
348 | } |
349 | |
350 | /** Up-casting assignment operator. |
351 | |
352 | Does not work for up-casts to ambiguous bases. |
353 | |
354 | @param rRef another VclPtr |
355 | */ |
356 | template<typename derived_type> |
357 | typename std::enable_if< |
358 | std::is_base_of<reference_type, derived_type>::value, |
359 | ScopedVclPtr &>::type |
360 | operator =(VclPtr<derived_type> const & rRef) |
361 | { |
362 | disposeAndReset(rRef.get()); |
363 | return *this; |
364 | } |
365 | |
366 | /** |
367 | * Override and disallow this, to prevent people accidentally calling it and actually |
368 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
369 | */ |
370 | template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete; |
371 | |
372 | ~ScopedVclPtr() |
373 | { |
374 | VclPtr<reference_type>::disposeAndClear(); |
375 | assert(VclPtr<reference_type>::get() == nullptr)(static_cast <bool> (VclPtr<reference_type>::get( ) == nullptr) ? void (0) : __assert_fail ("VclPtr<reference_type>::get() == nullptr" , "/home/maarten/src/libreoffice/core/include/vcl/vclptr.hxx" , 375, __extension__ __PRETTY_FUNCTION__)); // make sure there are no lingering references |
376 | } |
377 | |
378 | private: |
379 | // Most likely we don't want this default copy-constructor. |
380 | ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete; |
381 | // And certainly we don't want a default assignment operator. |
382 | ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete; |
383 | // And disallow reset as that doesn't call disposeAndClear on the original reference |
384 | void reset() = delete; |
385 | void reset(reference_type *pBody) = delete; |
386 | |
387 | protected: |
388 | ScopedVclPtr (reference_type * pBody, __sal_NoAcquire) |
389 | : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE) |
390 | {} |
391 | }; |
392 | |
393 | /** |
394 | * A construction helper for ScopedVclPtr. Since VclPtr types are created |
395 | * with a reference-count of one - to help fit into the existing |
396 | * code-flow; this helps us to construct them easily. |
397 | * |
398 | * For more details on the design please see vcl/README.lifecycle |
399 | * |
400 | * @param reference_type must be a subclass of vcl::Window |
401 | */ |
402 | #if defined _MSC_VER |
403 | #pragma warning(push) |
404 | #pragma warning(disable: 4521) // " multiple copy constructors specified" |
405 | #endif |
406 | template <class reference_type> |
407 | class SAL_WARN_UNUSED__attribute__((warn_unused)) ScopedVclPtrInstance final : public ScopedVclPtr<reference_type> |
408 | { |
409 | public: |
410 | template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg) |
411 | : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) |
412 | { |
413 | } |
414 | |
415 | /** |
416 | * Override and disallow this, to prevent people accidentally calling it and actually |
417 | * getting VclPtr::Create and getting a naked VclPtr<> instance |
418 | */ |
419 | template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete; |
420 | |
421 | private: |
422 | // Prevent the above perfect forwarding ctor from hijacking (accidental) |
423 | // attempts at ScopedVclPtrInstance copy construction (where the hijacking |
424 | // would typically lead to somewhat obscure error messages); both non-const |
425 | // and const variants are needed here, as the ScopedVclPtr base class has a |
426 | // const--variant copy ctor, so the implicitly declared copy ctor for |
427 | // ScopedVclPtrInstance would also be the const variant, so non-const copy |
428 | // construction attempts would be hijacked by the perfect forwarding ctor; |
429 | // but if we only declared a non-const variant here, the const variant would |
430 | // no longer be implicitly declared (as there would already be an explicitly |
431 | // declared copy ctor), so const copy construction attempts would then be |
432 | // hijacked by the perfect forwarding ctor: |
433 | ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete; |
434 | ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete; |
435 | }; |
436 | #if defined _MSC_VER |
437 | #pragma warning(pop) |
438 | #endif |
439 | |
440 | #endif // INCLUDED_VCL_PTR_HXX |
441 | |
442 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||||||||
2 | /* | ||||||||
3 | * This file is part of the LibreOffice project. | ||||||||
4 | * | ||||||||
5 | * This Source Code Form is subject to the terms of the Mozilla Public | ||||||||
6 | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||||||||
7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||||||||
8 | * | ||||||||
9 | * This file incorporates work covered by the following license notice: | ||||||||
10 | * | ||||||||
11 | * Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||
12 | * contributor license agreements. See the NOTICE file distributed | ||||||||
13 | * with this work for additional information regarding copyright | ||||||||
14 | * ownership. The ASF licenses this file to you under the Apache | ||||||||
15 | * License, Version 2.0 (the "License"); you may not use this file | ||||||||
16 | * except in compliance with the License. You may obtain a copy of | ||||||||
17 | * the License at http://www.apache.org/licenses/LICENSE-2.0 . | ||||||||
18 | */ | ||||||||
19 | |||||||||
20 | #ifndef INCLUDED_RTL_REF_HXX | ||||||||
21 | #define INCLUDED_RTL_REF_HXX | ||||||||
22 | |||||||||
23 | #include "sal/config.h" | ||||||||
24 | |||||||||
25 | #include <cassert> | ||||||||
26 | #include <cstddef> | ||||||||
27 | #include <functional> | ||||||||
28 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
29 | #include <type_traits> | ||||||||
30 | #endif | ||||||||
31 | |||||||||
32 | #include "sal/types.h" | ||||||||
33 | |||||||||
34 | namespace rtl | ||||||||
35 | { | ||||||||
36 | |||||||||
37 | /** Template reference class for reference type. | ||||||||
38 | */ | ||||||||
39 | template <class reference_type> | ||||||||
40 | class Reference | ||||||||
41 | { | ||||||||
42 | /** The <b>reference_type</b> body pointer. | ||||||||
43 | */ | ||||||||
44 | reference_type * m_pBody; | ||||||||
45 | |||||||||
46 | |||||||||
47 | public: | ||||||||
48 | /** Constructor... | ||||||||
49 | */ | ||||||||
50 | Reference() | ||||||||
51 | : m_pBody (NULL__null) | ||||||||
52 | {} | ||||||||
53 | |||||||||
54 | |||||||||
55 | /** Constructor... | ||||||||
56 | */ | ||||||||
57 | Reference (reference_type * pBody, __sal_NoAcquire) | ||||||||
58 | : m_pBody (pBody) | ||||||||
59 | { | ||||||||
60 | } | ||||||||
61 | |||||||||
62 | /** Constructor... | ||||||||
63 | */ | ||||||||
64 | Reference (reference_type * pBody) | ||||||||
65 | : m_pBody (pBody) | ||||||||
66 | { | ||||||||
67 | if (m_pBody) | ||||||||
68 | m_pBody->acquire(); | ||||||||
69 | } | ||||||||
70 | |||||||||
71 | /** Copy constructor... | ||||||||
72 | */ | ||||||||
73 | Reference (const Reference<reference_type> & handle) | ||||||||
74 | : m_pBody (handle.m_pBody) | ||||||||
75 | { | ||||||||
76 | if (m_pBody) | ||||||||
77 | m_pBody->acquire(); | ||||||||
78 | } | ||||||||
79 | |||||||||
80 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
81 | /** Move constructor... | ||||||||
82 | */ | ||||||||
83 | Reference (Reference<reference_type> && handle) noexcept | ||||||||
84 | : m_pBody (handle.m_pBody) | ||||||||
85 | { | ||||||||
86 | handle.m_pBody = nullptr; | ||||||||
87 | } | ||||||||
88 | #endif | ||||||||
89 | |||||||||
90 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
91 | /** Up-casting conversion constructor: Copies interface reference. | ||||||||
92 | |||||||||
93 | Does not work for up-casts to ambiguous bases. | ||||||||
94 | |||||||||
95 | @param rRef another reference | ||||||||
96 | */ | ||||||||
97 | template< class derived_type > | ||||||||
98 | inline Reference( | ||||||||
99 | const Reference< derived_type > & rRef, | ||||||||
100 | std::enable_if_t<std::is_base_of_v<reference_type, derived_type>, int> = 0 ) | ||||||||
101 | : m_pBody (rRef.get()) | ||||||||
102 | { | ||||||||
103 | if (m_pBody) | ||||||||
104 | m_pBody->acquire(); | ||||||||
105 | } | ||||||||
106 | #endif | ||||||||
107 | |||||||||
108 | /** Destructor... | ||||||||
109 | */ | ||||||||
110 | ~Reference() COVERITY_NOEXCEPT_FALSE | ||||||||
111 | { | ||||||||
112 | if (m_pBody
| ||||||||
113 | m_pBody->release(); | ||||||||
114 | } | ||||||||
115 | |||||||||
116 | /** Set... | ||||||||
117 | Similar to assignment. | ||||||||
118 | */ | ||||||||
119 | Reference<reference_type> & | ||||||||
120 | SAL_CALL set (reference_type * pBody) | ||||||||
121 | { | ||||||||
122 | if (pBody) | ||||||||
123 | pBody->acquire(); | ||||||||
124 | reference_type * const pOld = m_pBody; | ||||||||
125 | m_pBody = pBody; | ||||||||
126 | if (pOld) | ||||||||
127 | pOld->release(); | ||||||||
128 | return *this; | ||||||||
129 | } | ||||||||
130 | |||||||||
131 | /** Assignment. | ||||||||
132 | Unbinds this instance from its body (if bound) and | ||||||||
133 | bind it to the body represented by the handle. | ||||||||
134 | */ | ||||||||
135 | Reference<reference_type> & | ||||||||
136 | SAL_CALL operator= (const Reference<reference_type> & handle) | ||||||||
137 | { | ||||||||
138 | return set( handle.m_pBody ); | ||||||||
139 | } | ||||||||
140 | |||||||||
141 | #ifdef LIBO_INTERNAL_ONLY1 | ||||||||
142 | /** Assignment. | ||||||||
143 | * Unbinds this instance from its body (if bound), | ||||||||
144 | * bind it to the body represented by the handle, and | ||||||||
145 | * set the body represented by the handle to nullptr. | ||||||||
146 | */ | ||||||||
147 | Reference<reference_type> & | ||||||||
148 | operator= (Reference<reference_type> && handle) | ||||||||
149 | { | ||||||||
150 | // self-movement guts ourself | ||||||||
151 | if (m_pBody) | ||||||||
152 | m_pBody->release(); | ||||||||
153 | m_pBody = handle.m_pBody; | ||||||||
154 | handle.m_pBody = nullptr; | ||||||||
155 | return *this; | ||||||||
156 | } | ||||||||
157 | #endif | ||||||||
158 | |||||||||
159 | /** Assignment... | ||||||||
160 | */ | ||||||||
161 | Reference<reference_type> & | ||||||||
162 | SAL_CALL operator= (reference_type * pBody) | ||||||||
163 | { | ||||||||
164 | return set( pBody ); | ||||||||
165 | } | ||||||||
166 | |||||||||
167 | /** Unbind the body from this handle. | ||||||||
168 | Note that for a handle representing a large body, | ||||||||
169 | "handle.clear().set(new body());" _might_ | ||||||||
170 | perform a little bit better than "handle.set(new body());", | ||||||||
171 | since in the second case two large objects exist in memory | ||||||||
172 | (the old body and the new body). | ||||||||
173 | */ | ||||||||
174 | Reference<reference_type> & SAL_CALL clear() | ||||||||
175 | { | ||||||||
176 | if (m_pBody) | ||||||||
177 | { | ||||||||
178 | reference_type * const pOld = m_pBody; | ||||||||
179 | m_pBody = NULL__null; | ||||||||
180 | pOld->release(); | ||||||||
181 | } | ||||||||
182 | return *this; | ||||||||
183 | } | ||||||||
184 | |||||||||
185 | |||||||||
186 | /** Get the body. Can be used instead of operator->(). | ||||||||
187 | I.e. handle->someBodyOp() and handle.get()->someBodyOp() | ||||||||
188 | are the same. | ||||||||
189 | */ | ||||||||
190 | reference_type * SAL_CALL get() const | ||||||||
191 | { | ||||||||
192 | return m_pBody; | ||||||||
| |||||||||
193 | } | ||||||||
194 | |||||||||
195 | |||||||||
196 | /** Probably most common used: handle->someBodyOp(). | ||||||||
197 | */ | ||||||||
198 | reference_type * SAL_CALL operator->() const | ||||||||
199 | { | ||||||||
200 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 200, __extension__ __PRETTY_FUNCTION__)); | ||||||||
201 | return m_pBody; | ||||||||
202 | } | ||||||||
203 | |||||||||
204 | |||||||||
205 | /** Allows (*handle).someBodyOp(). | ||||||||
206 | */ | ||||||||
207 | reference_type & SAL_CALL operator*() const | ||||||||
208 | { | ||||||||
209 | assert(m_pBody != NULL)(static_cast <bool> (m_pBody != __null) ? void (0) : __assert_fail ("m_pBody != NULL", "/home/maarten/src/libreoffice/core/include/rtl/ref.hxx" , 209, __extension__ __PRETTY_FUNCTION__)); | ||||||||
210 | return *m_pBody; | ||||||||
211 | } | ||||||||
212 | |||||||||
213 | |||||||||
214 | /** Returns True if the handle does point to a valid body. | ||||||||
215 | */ | ||||||||
216 | bool SAL_CALL is() const | ||||||||
217 | { | ||||||||
218 | return (m_pBody != NULL__null); | ||||||||
219 | } | ||||||||
220 | |||||||||
221 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
222 | /** Returns True if the handle does point to a valid body. | ||||||||
223 | */ | ||||||||
224 | explicit operator bool() const | ||||||||
225 | { | ||||||||
226 | return is(); | ||||||||
227 | } | ||||||||
228 | #endif | ||||||||
229 | |||||||||
230 | /** Returns True if this points to pBody. | ||||||||
231 | */ | ||||||||
232 | bool SAL_CALL operator== (const reference_type * pBody) const | ||||||||
233 | { | ||||||||
234 | return (m_pBody == pBody); | ||||||||
235 | } | ||||||||
236 | |||||||||
237 | |||||||||
238 | /** Returns True if handle points to the same body. | ||||||||
239 | */ | ||||||||
240 | bool | ||||||||
241 | SAL_CALL operator== (const Reference<reference_type> & handle) const | ||||||||
242 | { | ||||||||
243 | return (m_pBody == handle.m_pBody); | ||||||||
244 | } | ||||||||
245 | |||||||||
246 | |||||||||
247 | /** Needed to place References into STL collection. | ||||||||
248 | */ | ||||||||
249 | bool | ||||||||
250 | SAL_CALL operator!= (const Reference<reference_type> & handle) const | ||||||||
251 | { | ||||||||
252 | return (m_pBody != handle.m_pBody); | ||||||||
253 | } | ||||||||
254 | |||||||||
255 | |||||||||
256 | /** Needed to place References into STL collection. | ||||||||
257 | */ | ||||||||
258 | bool | ||||||||
259 | SAL_CALL operator< (const Reference<reference_type> & handle) const | ||||||||
260 | { | ||||||||
261 | return (m_pBody < handle.m_pBody); | ||||||||
262 | } | ||||||||
263 | |||||||||
264 | |||||||||
265 | /** Needed to place References into STL collection. | ||||||||
266 | */ | ||||||||
267 | bool | ||||||||
268 | SAL_CALL operator> (const Reference<reference_type> & handle) const | ||||||||
269 | { | ||||||||
270 | return (m_pBody > handle.m_pBody); | ||||||||
271 | } | ||||||||
272 | }; | ||||||||
273 | |||||||||
274 | } // namespace rtl | ||||||||
275 | |||||||||
276 | #if defined LIBO_INTERNAL_ONLY1 | ||||||||
277 | namespace std | ||||||||
278 | { | ||||||||
279 | |||||||||
280 | /// @cond INTERNAL | ||||||||
281 | /** | ||||||||
282 | Make rtl::Reference hashable by default for use in STL containers. | ||||||||
283 | |||||||||
284 | @since LibreOffice 6.3 | ||||||||
285 | */ | ||||||||
286 | template<typename T> | ||||||||
287 | struct hash<::rtl::Reference<T>> | ||||||||
288 | { | ||||||||
289 | std::size_t operator()(::rtl::Reference<T> const & s) const | ||||||||
290 | { return std::size_t(s.get()); } | ||||||||
291 | }; | ||||||||
292 | /// @endcond | ||||||||
293 | |||||||||
294 | } | ||||||||
295 | |||||||||
296 | #endif | ||||||||
297 | |||||||||
298 | #endif /* ! INCLUDED_RTL_REF_HXX */ | ||||||||
299 | |||||||||
300 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |
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 | #ifndef INCLUDED_VCL_Reference_HXX |
20 | #define INCLUDED_VCL_Reference_HXX |
21 | |
22 | #include <vcl/dllapi.h> |
23 | #include <osl/interlck.h> |
24 | |
25 | class VCL_DLLPUBLIC__attribute__ ((visibility("default"))) VclReferenceBase |
26 | { |
27 | mutable oslInterlockedCount mnRefCnt; |
28 | |
29 | template<typename T> friend class VclPtr; |
30 | |
31 | public: |
32 | void acquire() const |
33 | { |
34 | osl_atomic_increment(&mnRefCnt)__sync_add_and_fetch((&mnRefCnt), 1); |
35 | } |
36 | |
37 | void release() const |
38 | { |
39 | if (osl_atomic_decrement(&mnRefCnt)__sync_sub_and_fetch((&mnRefCnt), 1) == 0) |
40 | delete this; |
41 | } |
42 | #ifdef DBG_UTIL |
43 | #ifndef _WIN32 |
44 | sal_Int32 getRefCount() const { return mnRefCnt; } |
45 | #endif |
46 | #endif |
47 | |
48 | |
49 | private: |
50 | VclReferenceBase(const VclReferenceBase&) = delete; |
51 | VclReferenceBase& operator=(const VclReferenceBase&) = delete; |
52 | |
53 | bool mbDisposed : 1; |
54 | |
55 | protected: |
56 | VclReferenceBase(); |
57 | protected: |
58 | virtual ~VclReferenceBase(); |
59 | |
60 | protected: |
61 | virtual void dispose(); |
62 | |
63 | public: |
64 | void disposeOnce(); |
65 | bool isDisposed() const { return mbDisposed; } |
66 | |
67 | }; |
68 | #endif |