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 <config_features.h> | |||
21 | ||||
22 | #include <com/sun/star/i18n/TextConversionOption.hpp> | |||
23 | #include <com/sun/star/sheet/DataPilotFieldFilter.hpp> | |||
24 | ||||
25 | #include <scitems.hxx> | |||
26 | #include <sfx2/viewfrm.hxx> | |||
27 | ||||
28 | #include <basic/sberrors.hxx> | |||
29 | #include <comphelper/lok.hxx> | |||
30 | #include <comphelper/propertysequence.hxx> | |||
31 | #include <svl/stritem.hxx> | |||
32 | #include <svl/zforlist.hxx> | |||
33 | #include <svl/zformat.hxx> | |||
34 | #include <sfx2/dispatch.hxx> | |||
35 | #include <sfx2/request.hxx> | |||
36 | #include <vcl/commandinfoprovider.hxx> | |||
37 | #include <vcl/svapp.hxx> | |||
38 | #include <vcl/weld.hxx> | |||
39 | #include <svx/svxdlg.hxx> | |||
40 | #include <sot/formats.hxx> | |||
41 | #include <svx/postattr.hxx> | |||
42 | #include <editeng/fontitem.hxx> | |||
43 | #include <svx/clipfmtitem.hxx> | |||
44 | #include <svx/hlnkitem.hxx> | |||
45 | #include <basic/sbxcore.hxx> | |||
46 | #include <editeng/editview.hxx> | |||
47 | #include <svtools/cliplistener.hxx> | |||
48 | ||||
49 | #include <cellsh.hxx> | |||
50 | #include <ftools.hxx> | |||
51 | #include <sc.hrc> | |||
52 | #include <document.hxx> | |||
53 | #include <patattr.hxx> | |||
54 | #include <scmod.hxx> | |||
55 | #include <tabvwsh.hxx> | |||
56 | #include <uiitems.hxx> | |||
57 | #include <reffact.hxx> | |||
58 | #include <inputhdl.hxx> | |||
59 | #include <transobj.hxx> | |||
60 | #include <drwtrans.hxx> | |||
61 | #include <docfunc.hxx> | |||
62 | #include <editable.hxx> | |||
63 | #include <dpobject.hxx> | |||
64 | #include <dpsave.hxx> | |||
65 | #include <spellparam.hxx> | |||
66 | #include <postit.hxx> | |||
67 | #include <dpsdbtab.hxx> | |||
68 | #include <dpshttab.hxx> | |||
69 | #include <dbdata.hxx> | |||
70 | #include <docsh.hxx> | |||
71 | #include <cliputil.hxx> | |||
72 | #include <markdata.hxx> | |||
73 | #include <colorscale.hxx> | |||
74 | #include <condformatdlg.hxx> | |||
75 | #include <attrib.hxx> | |||
76 | #include <condformatdlgitem.hxx> | |||
77 | #include <impex.hxx> | |||
78 | ||||
79 | #include <globstr.hrc> | |||
80 | #include <scresid.hxx> | |||
81 | #include <scui_def.hxx> | |||
82 | #include <scabstdlg.hxx> | |||
83 | #include <tokenstringcontext.hxx> | |||
84 | #include <cellvalue.hxx> | |||
85 | #include <tokenarray.hxx> | |||
86 | #include <formulacell.hxx> | |||
87 | #include <gridwin.hxx> | |||
88 | #include <searchresults.hxx> | |||
89 | ||||
90 | #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> | |||
91 | #include <com/sun/star/lang/XInitialization.hpp> | |||
92 | #include <com/sun/star/beans/XPropertySet.hpp> | |||
93 | #include <com/sun/star/uno/XComponentContext.hpp> | |||
94 | #include <cppuhelper/bootstrap.hxx> | |||
95 | ||||
96 | #include <memory> | |||
97 | ||||
98 | using namespace ::com::sun::star; | |||
99 | using namespace ::com::sun::star::beans; | |||
100 | using namespace ::com::sun::star::uno; | |||
101 | ||||
102 | namespace{ | |||
103 | InsertDeleteFlags FlagsFromString(const OUString& rFlagsStr, | |||
104 | InsertDeleteFlags nFlagsMask = InsertDeleteFlags::CONTENTS | InsertDeleteFlags::ATTRIB) | |||
105 | { | |||
106 | OUString aFlagsStr = rFlagsStr.toAsciiUpperCase(); | |||
107 | InsertDeleteFlags nFlags = InsertDeleteFlags::NONE; | |||
108 | ||||
109 | for (sal_Int32 i=0 ; i < aFlagsStr.getLength(); ++i) | |||
110 | { | |||
111 | switch (aFlagsStr[i]) | |||
112 | { | |||
113 | case 'A': return InsertDeleteFlags::ALL; | |||
114 | case 'S': nFlags |= InsertDeleteFlags::STRING & nFlagsMask; break; | |||
115 | case 'V': nFlags |= InsertDeleteFlags::VALUE & nFlagsMask; break; | |||
116 | case 'D': nFlags |= InsertDeleteFlags::DATETIME & nFlagsMask; break; | |||
117 | case 'F': nFlags |= InsertDeleteFlags::FORMULA & nFlagsMask; break; | |||
118 | case 'N': nFlags |= InsertDeleteFlags::NOTE & nFlagsMask; break; | |||
119 | case 'T': nFlags |= InsertDeleteFlags::ATTRIB & nFlagsMask; break; | |||
120 | case 'O': nFlags |= InsertDeleteFlags::OBJECTS & nFlagsMask; break; | |||
121 | } | |||
122 | } | |||
123 | return nFlags; | |||
124 | } | |||
125 | ||||
126 | OUString FlagsToString( InsertDeleteFlags nFlags, | |||
127 | InsertDeleteFlags nFlagsMask = InsertDeleteFlags::CONTENTS | InsertDeleteFlags::ATTRIB ) | |||
128 | { | |||
129 | OUString aFlagsStr; | |||
130 | ||||
131 | if( nFlags == InsertDeleteFlags::ALL ) | |||
132 | { | |||
133 | aFlagsStr = "A"; | |||
134 | } | |||
135 | else | |||
136 | { | |||
137 | nFlags &= nFlagsMask; | |||
138 | ||||
139 | if( nFlags & InsertDeleteFlags::STRING ) aFlagsStr += "S"; | |||
140 | if( nFlags & InsertDeleteFlags::VALUE ) aFlagsStr += "V"; | |||
141 | if( nFlags & InsertDeleteFlags::DATETIME ) aFlagsStr += "D"; | |||
142 | if( nFlags & InsertDeleteFlags::FORMULA ) aFlagsStr += "F"; | |||
143 | if( nFlags & InsertDeleteFlags::NOTE ) aFlagsStr += "N"; | |||
144 | if( nFlags & InsertDeleteFlags::ATTRIB ) aFlagsStr += "T"; | |||
145 | if( nFlags & InsertDeleteFlags::OBJECTS ) aFlagsStr += "O"; | |||
146 | } | |||
147 | return aFlagsStr; | |||
148 | } | |||
149 | ||||
150 | void SetTabNoAndCursor( const ScViewData* rViewData, const OUString& rCellId ) | |||
151 | { | |||
152 | ScTabViewShell* pTabViewShell = rViewData->GetViewShell(); | |||
153 | assert(pTabViewShell)(static_cast <bool> (pTabViewShell) ? void (0) : __assert_fail ("pTabViewShell", "/home/maarten/src/libreoffice/core/sc/source/ui/view/cellsh1.cxx" , 153, __extension__ __PRETTY_FUNCTION__)); | |||
154 | const ScDocument& rDoc = rViewData->GetDocShell()->GetDocument(); | |||
155 | std::vector<sc::NoteEntry> aNotes; | |||
156 | rDoc.GetAllNoteEntries(aNotes); | |||
157 | ||||
158 | sal_uInt32 nId = rCellId.toUInt32(); | |||
159 | auto lComp = [nId](const sc::NoteEntry& rNote) { return rNote.mpNote->GetId() == nId; }; | |||
160 | ||||
161 | const auto& aFoundNoteIt = std::find_if(aNotes.begin(), aNotes.end(), lComp); | |||
162 | if (aFoundNoteIt != aNotes.end()) | |||
163 | { | |||
164 | ScAddress aFoundPos = aFoundNoteIt->maPos; | |||
165 | pTabViewShell->SetTabNo(aFoundPos.Tab()); | |||
166 | pTabViewShell->SetCursor(aFoundPos.Col(), aFoundPos.Row()); | |||
167 | } | |||
168 | } | |||
169 | } | |||
170 | ||||
171 | void ScCellShell::ExecuteEdit( SfxRequest& rReq ) | |||
172 | { | |||
173 | ScModule* pScMod = SC_MOD()( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule ::Calc)) ); | |||
174 | ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); | |||
175 | SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings(); | |||
176 | const SfxItemSet* pReqArgs = rReq.GetArgs(); | |||
177 | sal_uInt16 nSlot = rReq.GetSlot(); | |||
178 | ||||
179 | pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox | |||
180 | ||||
181 | // finish input | |||
182 | if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) ) | |||
| ||||
183 | { | |||
184 | switch ( nSlot ) | |||
185 | { | |||
186 | case FID_DEFINE_NAME((((((((26000 + 200) + 20)) + 20)) + 20)) + 11): | |||
187 | case FID_ADD_NAME((((((((26000 + 200) + 20)) + 20)) + 20)) + 16): | |||
188 | case FID_USE_NAME((((((((26000 + 200) + 20)) + 20)) + 20)) + 13): | |||
189 | case FID_INSERT_NAME((((((((26000 + 200) + 20)) + 20)) + 20)) + 12): | |||
190 | case SID_SPELL_DIALOG( 10000 + 243 ): | |||
191 | case SID_HANGUL_HANJA_CONVERSION( 10000 + 959 ): | |||
192 | case SID_OPENDLG_CONDFRMT((26000 + 100) + 59): | |||
193 | case SID_OPENDLG_CURRENTCONDFRMT((26000 + 100) + 58): | |||
194 | case SID_OPENDLG_COLORSCALE((26000 + 100) + 66): | |||
195 | case SID_OPENDLG_DATABAR((26000 + 100) + 67): | |||
196 | pScMod->InputEnterHandler(); | |||
197 | pTabViewShell->UpdateInputHandler(); | |||
198 | break; | |||
199 | ||||
200 | default: | |||
201 | break; | |||
202 | } | |||
203 | } | |||
204 | ||||
205 | switch ( nSlot ) | |||
206 | { | |||
207 | ||||
208 | // insert / delete cells / rows / columns | |||
209 | ||||
210 | case FID_INS_ROW((((((((26000 + 200) + 20)) + 20)) + 20)) + 7): | |||
211 | case FID_INS_ROWS_BEFORE((((((((26000 + 200) + 20)) + 20)) + 20)) + 22): | |||
212 | pTabViewShell->InsertCells(INS_INSROWS_BEFORE); | |||
213 | rReq.Done(); | |||
214 | break; | |||
215 | ||||
216 | case FID_INS_COLUMN((((((((26000 + 200) + 20)) + 20)) + 20)) + 8): | |||
217 | case FID_INS_COLUMNS_BEFORE((((((((26000 + 200) + 20)) + 20)) + 20)) + 23): | |||
218 | pTabViewShell->InsertCells(INS_INSCOLS_BEFORE); | |||
219 | rReq.Done(); | |||
220 | break; | |||
221 | ||||
222 | case FID_INS_ROWS_AFTER((((((((26000 + 200) + 20)) + 20)) + 20)) + 20): | |||
223 | pTabViewShell->InsertCells(INS_INSROWS_AFTER); | |||
224 | rReq.Done(); | |||
225 | break; | |||
226 | ||||
227 | case FID_INS_COLUMNS_AFTER((((((((26000 + 200) + 20)) + 20)) + 20)) + 21): | |||
228 | pTabViewShell->InsertCells(INS_INSCOLS_AFTER); | |||
229 | rReq.Done(); | |||
230 | break; | |||
231 | ||||
232 | case FID_INS_CELLSDOWN((((((((26000 + 200) + 20)) + 20)) + 20)) + 18): | |||
233 | pTabViewShell->InsertCells(INS_CELLSDOWN); | |||
234 | rReq.Done(); | |||
235 | break; | |||
236 | ||||
237 | case FID_INS_CELLSRIGHT((((((((26000 + 200) + 20)) + 20)) + 20)) + 19): | |||
238 | pTabViewShell->InsertCells(INS_CELLSRIGHT); | |||
239 | rReq.Done(); | |||
240 | break; | |||
241 | ||||
242 | case SID_DEL_ROWS((((26000 + 200) + 20)) + 16): | |||
243 | pTabViewShell->DeleteCells( DelCellCmd::Rows ); | |||
244 | rReq.Done(); | |||
245 | break; | |||
246 | ||||
247 | case SID_DEL_COLS((((26000 + 200) + 20)) + 17): | |||
248 | pTabViewShell->DeleteCells( DelCellCmd::Cols ); | |||
249 | rReq.Done(); | |||
250 | break; | |||
251 | ||||
252 | case FID_INS_CELL((((((((26000 + 200) + 20)) + 20)) + 20)) + 6): | |||
253 | { | |||
254 | InsCellCmd eCmd=INS_NONE; | |||
255 | ||||
256 | if ( pReqArgs ) | |||
257 | { | |||
258 | const SfxPoolItem* pItem; | |||
259 | OUString aFlags; | |||
260 | ||||
261 | if( pReqArgs->HasItem( FID_INS_CELL((((((((26000 + 200) + 20)) + 20)) + 20)) + 6), &pItem ) ) | |||
262 | aFlags = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
263 | if( !aFlags.isEmpty() ) | |||
264 | { | |||
265 | switch( aFlags[0] ) | |||
266 | { | |||
267 | case 'V': eCmd = INS_CELLSDOWN ;break; | |||
268 | case '>': eCmd = INS_CELLSRIGHT ;break; | |||
269 | case 'R': eCmd = INS_INSROWS_BEFORE ;break; | |||
270 | case 'C': eCmd = INS_INSCOLS_BEFORE ;break; | |||
271 | } | |||
272 | } | |||
273 | } | |||
274 | else | |||
275 | { | |||
276 | if ( GetViewData()->SimpleColMarked() ) | |||
277 | eCmd = INS_INSCOLS_BEFORE; | |||
278 | else if ( GetViewData()->SimpleRowMarked() ) | |||
279 | eCmd = INS_INSROWS_BEFORE; | |||
280 | else | |||
281 | { | |||
282 | ScDocument& rDoc = GetViewData()->GetDocument(); | |||
283 | bool bTheFlag=(rDoc.GetChangeTrack()!=nullptr); | |||
284 | ||||
285 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
286 | ||||
287 | ScopedVclPtr<AbstractScInsertCellDlg> pDlg(pFact->CreateScInsertCellDlg(pTabViewShell->GetFrameWeld(), bTheFlag)); | |||
288 | if (pDlg->Execute() == RET_OK) | |||
289 | eCmd = pDlg->GetInsCellCmd(); | |||
290 | } | |||
291 | } | |||
292 | ||||
293 | if (eCmd!=INS_NONE) | |||
294 | { | |||
295 | pTabViewShell->InsertCells( eCmd ); | |||
296 | ||||
297 | if( ! rReq.IsAPI() ) | |||
298 | { | |||
299 | OUString aParam; | |||
300 | ||||
301 | switch( eCmd ) | |||
302 | { | |||
303 | case INS_CELLSDOWN: aParam = "V"; break; | |||
304 | case INS_CELLSRIGHT: aParam = ">"; break; | |||
305 | case INS_INSROWS_BEFORE: aParam = "R"; break; | |||
306 | case INS_INSCOLS_BEFORE: aParam = "C"; break; | |||
307 | default: | |||
308 | { | |||
309 | // added to avoid warnings | |||
310 | } | |||
311 | } | |||
312 | rReq.AppendItem( SfxStringItem( FID_INS_CELL((((((((26000 + 200) + 20)) + 20)) + 20)) + 6), aParam ) ); | |||
313 | rReq.Done(); | |||
314 | } | |||
315 | } | |||
316 | } | |||
317 | break; | |||
318 | ||||
319 | case FID_DELETE_CELL((((26000 + 200) + 20)) + 2): | |||
320 | { | |||
321 | DelCellCmd eCmd = DelCellCmd::NONE; | |||
322 | ||||
323 | if ( pReqArgs ) | |||
324 | { | |||
325 | const SfxPoolItem* pItem; | |||
326 | OUString aFlags; | |||
327 | ||||
328 | if( pReqArgs->HasItem( FID_DELETE_CELL((((26000 + 200) + 20)) + 2), &pItem ) ) | |||
329 | aFlags = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
330 | if( !aFlags.isEmpty() ) | |||
331 | { | |||
332 | switch( aFlags[0] ) | |||
333 | { | |||
334 | case 'U': eCmd = DelCellCmd::CellsUp ;break; | |||
335 | case 'L': eCmd = DelCellCmd::CellsLeft ;break; | |||
336 | case 'R': eCmd = DelCellCmd::Rows ;break; | |||
337 | case 'C': eCmd = DelCellCmd::Cols ;break; | |||
338 | } | |||
339 | } | |||
340 | } | |||
341 | else | |||
342 | { | |||
343 | if ( GetViewData()->SimpleColMarked() ) | |||
344 | eCmd = DelCellCmd::Cols; | |||
345 | else if ( GetViewData()->SimpleRowMarked() ) | |||
346 | eCmd = DelCellCmd::Rows; | |||
347 | else | |||
348 | { | |||
349 | ScRange aRange; | |||
350 | ScDocument& rDoc = GetViewData()->GetDocument(); | |||
351 | bool bTheFlag=GetViewData()->IsMultiMarked() || | |||
352 | (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE_FILTERED) || | |||
353 | (rDoc.GetChangeTrack() != nullptr); | |||
354 | ||||
355 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
356 | ||||
357 | ScopedVclPtr<AbstractScDeleteCellDlg> pDlg(pFact->CreateScDeleteCellDlg( pTabViewShell->GetFrameWeld(), bTheFlag )); | |||
358 | ||||
359 | if (pDlg->Execute() == RET_OK) | |||
360 | eCmd = pDlg->GetDelCellCmd(); | |||
361 | } | |||
362 | } | |||
363 | ||||
364 | if (eCmd != DelCellCmd::NONE ) | |||
365 | { | |||
366 | pTabViewShell->DeleteCells( eCmd ); | |||
367 | ||||
368 | if( ! rReq.IsAPI() ) | |||
369 | { | |||
370 | OUString aParam; | |||
371 | ||||
372 | switch( eCmd ) | |||
373 | { | |||
374 | case DelCellCmd::CellsUp: aParam = "U"; break; | |||
375 | case DelCellCmd::CellsLeft: aParam = "L"; break; | |||
376 | case DelCellCmd::Rows: aParam = "R"; break; | |||
377 | case DelCellCmd::Cols: aParam = "C"; break; | |||
378 | default: | |||
379 | { | |||
380 | // added to avoid warnings | |||
381 | } | |||
382 | } | |||
383 | rReq.AppendItem( SfxStringItem( FID_DELETE_CELL((((26000 + 200) + 20)) + 2), aParam ) ); | |||
384 | rReq.Done(); | |||
385 | } | |||
386 | } | |||
387 | } | |||
388 | break; | |||
389 | ||||
390 | // delete contents from cells | |||
391 | ||||
392 | case SID_DELETE_CONTENTS((26000 + 521) + 32): | |||
393 | pTabViewShell->DeleteContents( InsertDeleteFlags::CONTENTS ); | |||
394 | rReq.Done(); | |||
395 | break; | |||
396 | ||||
397 | case SID_DELETE(5000 + 713): | |||
398 | { | |||
399 | InsertDeleteFlags nFlags = InsertDeleteFlags::NONE; | |||
400 | ||||
401 | if ( pReqArgs!=nullptr && pTabViewShell->SelectionEditable() ) | |||
402 | { | |||
403 | const SfxPoolItem* pItem; | |||
404 | OUString aFlags('A'); | |||
405 | ||||
406 | if( pReqArgs->HasItem( SID_DELETE(5000 + 713), &pItem ) ) | |||
407 | aFlags = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
408 | ||||
409 | nFlags |= FlagsFromString(aFlags, InsertDeleteFlags::ALL); | |||
410 | } | |||
411 | else | |||
412 | { | |||
413 | ScEditableTester aTester( pTabViewShell ); | |||
414 | if (aTester.IsEditable()) | |||
415 | { | |||
416 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
417 | ||||
418 | ScopedVclPtr<AbstractScDeleteContentsDlg> pDlg(pFact->CreateScDeleteContentsDlg(pTabViewShell->GetFrameWeld())); | |||
419 | ScDocument& rDoc = GetViewData()->GetDocument(); | |||
420 | SCTAB nTab = GetViewData()->GetTabNo(); | |||
421 | if ( rDoc.IsTabProtected(nTab) ) | |||
422 | pDlg->DisableObjects(); | |||
423 | if (pDlg->Execute() == RET_OK) | |||
424 | { | |||
425 | nFlags = pDlg->GetDelContentsCmdBits(); | |||
426 | } | |||
427 | } | |||
428 | else | |||
429 | pTabViewShell->ErrorMessage(aTester.GetMessageId()); | |||
430 | } | |||
431 | ||||
432 | if( nFlags != InsertDeleteFlags::NONE ) | |||
433 | { | |||
434 | pTabViewShell->DeleteContents( nFlags ); | |||
435 | ||||
436 | if( ! rReq.IsAPI() ) | |||
437 | { | |||
438 | OUString aFlags = FlagsToString( nFlags, InsertDeleteFlags::ALL ); | |||
439 | ||||
440 | rReq.AppendItem( SfxStringItem( SID_DELETE(5000 + 713), aFlags ) ); | |||
441 | rReq.Done(); | |||
442 | } | |||
443 | } | |||
444 | } | |||
445 | break; | |||
446 | ||||
447 | // fill... | |||
448 | ||||
449 | case FID_FILL_TO_BOTTOM((((26000 + 200) + 20)) + 4): | |||
450 | pTabViewShell->FillSimple( FILL_TO_BOTTOM ); | |||
451 | rReq.Done(); | |||
452 | break; | |||
453 | ||||
454 | case FID_FILL_TO_RIGHT((((26000 + 200) + 20)) + 5): | |||
455 | pTabViewShell->FillSimple( FILL_TO_RIGHT ); | |||
456 | rReq.Done(); | |||
457 | break; | |||
458 | ||||
459 | case FID_FILL_TO_TOP((((26000 + 200) + 20)) + 6): | |||
460 | pTabViewShell->FillSimple( FILL_TO_TOP ); | |||
461 | rReq.Done(); | |||
462 | break; | |||
463 | ||||
464 | case FID_FILL_TO_LEFT((((26000 + 200) + 20)) + 7): | |||
465 | pTabViewShell->FillSimple( FILL_TO_LEFT ); | |||
466 | rReq.Done(); | |||
467 | break; | |||
468 | ||||
469 | case FID_FILL_TAB((((26000 + 200) + 20)) + 8): | |||
470 | { | |||
471 | InsertDeleteFlags nFlags = InsertDeleteFlags::NONE; | |||
472 | ScPasteFunc nFunction = ScPasteFunc::NONE; | |||
473 | bool bSkipEmpty = false; | |||
474 | bool bAsLink = false; | |||
475 | ||||
476 | if ( pReqArgs!=nullptr && pTabViewShell->SelectionEditable() ) | |||
477 | { | |||
478 | const SfxPoolItem* pItem; | |||
479 | OUString aFlags('A'); | |||
480 | ||||
481 | if( pReqArgs->HasItem( FID_FILL_TAB((((26000 + 200) + 20)) + 8), &pItem ) ) | |||
482 | aFlags = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
483 | ||||
484 | nFlags |= FlagsFromString(aFlags); | |||
485 | } | |||
486 | else | |||
487 | { | |||
488 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
489 | ||||
490 | ScopedVclPtr<AbstractScInsertContentsDlg> pDlg(pFact->CreateScInsertContentsDlg(pTabViewShell->GetFrameWeld(), | |||
491 | new OUString(ScResId(STR_FILL_TABreinterpret_cast<char const *>("STR_FILL_TAB" "\004" u8"Fill Sheets" ))))); | |||
492 | pDlg->SetFillMode(true); | |||
493 | ||||
494 | if (pDlg->Execute() == RET_OK) | |||
495 | { | |||
496 | nFlags = pDlg->GetInsContentsCmdBits(); | |||
497 | nFunction = pDlg->GetFormulaCmdBits(); | |||
498 | bSkipEmpty = pDlg->IsSkipEmptyCells(); | |||
499 | bAsLink = pDlg->IsLink(); | |||
500 | // there is no MoveMode with fill tabs | |||
501 | } | |||
502 | } | |||
503 | ||||
504 | if( nFlags != InsertDeleteFlags::NONE ) | |||
505 | { | |||
506 | pTabViewShell->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink ); | |||
507 | ||||
508 | if( ! rReq.IsAPI() ) | |||
509 | { | |||
510 | OUString aFlags = FlagsToString( nFlags ); | |||
511 | ||||
512 | rReq.AppendItem( SfxStringItem( FID_FILL_TAB((((26000 + 200) + 20)) + 8), aFlags ) ); | |||
513 | rReq.Done(); | |||
514 | } | |||
515 | } | |||
516 | } | |||
517 | break; | |||
518 | ||||
519 | case FID_FILL_SERIES((((26000 + 200) + 20)) + 9): | |||
520 | { | |||
521 | if (GetViewData()->SelectionForbidsCellFill()) | |||
522 | // Slot should be already disabled, but in case it wasn't | |||
523 | // don't even attempt to do the evaluation and popup a | |||
524 | // dialog. | |||
525 | break; | |||
526 | ||||
527 | SCCOL nStartCol; | |||
528 | SCROW nStartRow; | |||
529 | SCTAB nStartTab; | |||
530 | SCCOL nEndCol; | |||
531 | SCROW nEndRow; | |||
532 | SCTAB nEndTab; | |||
533 | sal_uInt16 nPossDir = FDS_OPT_NONE0; | |||
534 | FillDir eFillDir = FILL_TO_BOTTOM; | |||
535 | FillCmd eFillCmd = FILL_LINEAR; | |||
536 | FillDateCmd eFillDateCmd = FILL_DAY; | |||
537 | double fStartVal = MAXDOUBLE1.7e307; | |||
538 | double fIncVal = 1; | |||
539 | double fMaxVal = MAXDOUBLE1.7e307; | |||
540 | bool bDoIt = false; | |||
541 | ||||
542 | GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab, | |||
543 | nEndCol, nEndRow, nEndTab ); | |||
544 | ||||
545 | if( nStartCol!=nEndCol ) | |||
546 | { | |||
547 | nPossDir |= FDS_OPT_HORZ1; | |||
548 | eFillDir=FILL_TO_RIGHT; | |||
549 | } | |||
550 | ||||
551 | if( nStartRow!=nEndRow ) | |||
552 | { | |||
553 | nPossDir |= FDS_OPT_VERT2; | |||
554 | eFillDir=FILL_TO_BOTTOM; | |||
555 | } | |||
556 | ||||
557 | ScDocument& rDoc = GetViewData()->GetDocument(); | |||
558 | SvNumberFormatter* pFormatter = rDoc.GetFormatTable(); | |||
559 | ||||
560 | if( pReqArgs ) | |||
561 | { | |||
562 | const SfxPoolItem* pItem; | |||
563 | OUString aFillDir, aFillCmd, aFillDateCmd; | |||
564 | OUString aFillStep, aFillStart, aFillMax; | |||
565 | sal_uInt32 nKey; | |||
566 | double fTmpVal; | |||
567 | ||||
568 | if( pReqArgs->HasItem( FID_FILL_SERIES((((26000 + 200) + 20)) + 9), &pItem ) ) | |||
569 | aFillDir = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
570 | if( pReqArgs->HasItem( FN_PARAM_1((20000 + 1100)+60), &pItem ) ) | |||
571 | aFillCmd = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
572 | if( pReqArgs->HasItem( FN_PARAM_2((20000 + 1100)+61), &pItem ) ) | |||
573 | aFillDateCmd = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
574 | if( pReqArgs->HasItem( FN_PARAM_3((20000 + 1100)+62), &pItem ) ) | |||
575 | aFillStep = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
576 | if( pReqArgs->HasItem( FN_PARAM_4((20000 + 1100)+63), &pItem ) ) | |||
577 | aFillStart = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
578 | if( pReqArgs->HasItem( FN_PARAM_5((20000 + 1100)+64), &pItem ) ) | |||
579 | aFillMax = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
580 | ||||
581 | if( !aFillDir.isEmpty() ) | |||
582 | switch( aFillDir[0] ) | |||
583 | { | |||
584 | case 'B': case 'b': eFillDir=FILL_TO_BOTTOM; break; | |||
585 | case 'R': case 'r': eFillDir=FILL_TO_RIGHT; break; | |||
586 | case 'T': case 't': eFillDir=FILL_TO_TOP; break; | |||
587 | case 'L': case 'l': eFillDir=FILL_TO_LEFT; break; | |||
588 | } | |||
589 | ||||
590 | if( !aFillCmd.isEmpty() ) | |||
591 | switch( aFillCmd[0] ) | |||
592 | { | |||
593 | case 'S': case 's': eFillCmd=FILL_SIMPLE; break; | |||
594 | case 'L': case 'l': eFillCmd=FILL_LINEAR; break; | |||
595 | case 'G': case 'g': eFillCmd=FILL_GROWTH; break; | |||
596 | case 'D': case 'd': eFillCmd=FILL_DATE; break; | |||
597 | case 'A': case 'a': eFillCmd=FILL_AUTO; break; | |||
598 | } | |||
599 | ||||
600 | if( !aFillDateCmd.isEmpty() ) | |||
601 | switch( aFillDateCmd[0] ) | |||
602 | { | |||
603 | case 'D': case 'd': eFillDateCmd=FILL_DAY; break; | |||
604 | case 'W': case 'w': eFillDateCmd=FILL_WEEKDAY; break; | |||
605 | case 'M': case 'm': eFillDateCmd=FILL_MONTH; break; | |||
606 | case 'Y': case 'y': eFillDateCmd=FILL_YEAR; break; | |||
607 | } | |||
608 | ||||
609 | nKey = 0; | |||
610 | if( pFormatter->IsNumberFormat( aFillStart, nKey, fTmpVal )) | |||
611 | fStartVal = fTmpVal; | |||
612 | ||||
613 | nKey = 0; | |||
614 | if( pFormatter->IsNumberFormat( aFillStep, nKey, fTmpVal )) | |||
615 | fIncVal = fTmpVal; | |||
616 | ||||
617 | nKey = 0; | |||
618 | if( pFormatter->IsNumberFormat( aFillMax, nKey, fTmpVal )) | |||
619 | fMaxVal = fTmpVal; | |||
620 | ||||
621 | bDoIt = true; | |||
622 | ||||
623 | } | |||
624 | else // (pReqArgs == nullptr) => raise Dialog | |||
625 | { | |||
626 | sal_uInt32 nPrivFormat; | |||
627 | CellType eCellType; | |||
628 | rDoc.GetNumberFormat( nStartCol, nStartRow, nStartTab, nPrivFormat ); | |||
629 | rDoc.GetCellType( nStartCol, nStartRow, nStartTab,eCellType ); | |||
630 | const SvNumberformat* pPrivEntry = pFormatter->GetEntry( nPrivFormat ); | |||
631 | const SCSIZE nSelectHeight = nEndRow - nStartRow + 1; | |||
632 | const SCSIZE nSelectWidth = nEndCol - nStartCol + 1; | |||
633 | ||||
634 | if (!pPrivEntry) | |||
635 | { | |||
636 | OSL_FAIL("Numberformat not found !!!")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/cellsh1.cxx" ":" "636" ": "), "%s", "Numberformat not found !!!"); } } while (false); | |||
637 | } | |||
638 | else | |||
639 | { | |||
640 | SvNumFormatType nPrivType = pPrivEntry->GetType(); | |||
641 | if (nPrivType & SvNumFormatType::DATE) | |||
642 | { | |||
643 | eFillCmd=FILL_DATE; | |||
644 | } | |||
645 | else if(eCellType==CELLTYPE_STRING) | |||
646 | { | |||
647 | eFillCmd=FILL_AUTO; | |||
648 | } | |||
649 | } | |||
650 | ||||
651 | OUString aStartStr; | |||
652 | ||||
653 | // suggest default Startvalue only, when just 1 row or column | |||
654 | if ( nStartCol == nEndCol || nStartRow == nEndRow ) | |||
655 | { | |||
656 | double fInputEndVal = 0.0; | |||
657 | OUString aEndStr; | |||
658 | ||||
659 | rDoc.GetInputString( nStartCol, nStartRow, nStartTab, aStartStr); | |||
660 | rDoc.GetValue( nStartCol, nStartRow, nStartTab, fStartVal ); | |||
661 | ||||
662 | if(eFillDir==FILL_TO_BOTTOM && nStartRow < nEndRow ) | |||
663 | { | |||
664 | rDoc.GetInputString( nStartCol, nStartRow+1, nStartTab, aEndStr); | |||
665 | if(!aEndStr.isEmpty()) | |||
666 | { | |||
667 | rDoc.GetValue( nStartCol, nStartRow+1, nStartTab, fInputEndVal); | |||
668 | fIncVal=fInputEndVal-fStartVal; | |||
669 | } | |||
670 | } | |||
671 | else | |||
672 | { | |||
673 | if(nStartCol < nEndCol) | |||
674 | { | |||
675 | rDoc.GetInputString( nStartCol+1, nStartRow, nStartTab, aEndStr); | |||
676 | if(!aEndStr.isEmpty()) | |||
677 | { | |||
678 | rDoc.GetValue( nStartCol+1, nStartRow, nStartTab, fInputEndVal); | |||
679 | fIncVal=fInputEndVal-fStartVal; | |||
680 | } | |||
681 | } | |||
682 | } | |||
683 | if(eFillCmd==FILL_DATE) | |||
684 | { | |||
685 | const Date& rNullDate = rDoc.GetFormatTable()->GetNullDate(); | |||
686 | Date aStartDate = rNullDate; | |||
687 | aStartDate.AddDays(fStartVal); | |||
688 | Date aEndDate = rNullDate; | |||
689 | aEndDate.AddDays(fInputEndVal); | |||
690 | double fTempDate=0; | |||
691 | ||||
692 | if(aStartDate.GetYear()!=aEndDate.GetYear()) | |||
693 | { | |||
694 | eFillDateCmd = FILL_YEAR; | |||
695 | fTempDate=aEndDate.GetYear()-aStartDate.GetYear(); | |||
696 | } | |||
697 | if(aStartDate.GetMonth()!=aEndDate.GetMonth()) | |||
698 | { | |||
699 | eFillDateCmd = FILL_MONTH; | |||
700 | fTempDate=fTempDate*12+aEndDate.GetMonth()-aStartDate.GetMonth(); | |||
701 | } | |||
702 | if(aStartDate.GetDay()==aEndDate.GetDay()) | |||
703 | { | |||
704 | fIncVal=fTempDate; | |||
705 | } | |||
706 | } | |||
707 | } | |||
708 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
709 | ||||
710 | ScopedVclPtr<AbstractScFillSeriesDlg> pDlg(pFact->CreateScFillSeriesDlg( pTabViewShell->GetFrameWeld(), | |||
711 | rDoc, | |||
712 | eFillDir, eFillCmd, eFillDateCmd, | |||
713 | aStartStr, fIncVal, fMaxVal, | |||
714 | nSelectHeight, nSelectWidth, nPossDir)); | |||
715 | ||||
716 | if ( nStartCol != nEndCol && nStartRow != nEndRow ) | |||
717 | { | |||
718 | pDlg->SetEdStartValEnabled(false); | |||
719 | } | |||
720 | ||||
721 | if ( pDlg->Execute() == RET_OK ) | |||
722 | { | |||
723 | eFillDir = pDlg->GetFillDir(); | |||
724 | eFillCmd = pDlg->GetFillCmd(); | |||
725 | eFillDateCmd = pDlg->GetFillDateCmd(); | |||
726 | ||||
727 | if(eFillCmd==FILL_AUTO) | |||
728 | { | |||
729 | OUString aStr = pDlg->GetStartStr(); | |||
730 | if(!aStr.isEmpty()) | |||
731 | pTabViewShell->EnterData( nStartCol, nStartRow, nStartTab, aStr ); | |||
732 | } | |||
733 | fStartVal = pDlg->GetStart(); | |||
734 | fIncVal = pDlg->GetStep(); | |||
735 | fMaxVal = pDlg->GetMax(); | |||
736 | bDoIt = true; | |||
737 | } | |||
738 | } | |||
739 | ||||
740 | if( bDoIt ) | |||
741 | { | |||
742 | //nScFillModeMouseModifier = 0; // no Ctrl/Copy | |||
743 | pTabViewShell->FillSeries( eFillDir, eFillCmd, eFillDateCmd, fStartVal, fIncVal, fMaxVal ); | |||
744 | ||||
745 | if( ! rReq.IsAPI() ) | |||
746 | { | |||
747 | OUString aPara; | |||
748 | const Color* pColor = nullptr; | |||
749 | ||||
750 | switch( eFillDir ) | |||
751 | { | |||
752 | case FILL_TO_BOTTOM: aPara = "B"; break; | |||
753 | case FILL_TO_RIGHT: aPara = "R"; break; | |||
754 | case FILL_TO_TOP: aPara = "T"; break; | |||
755 | case FILL_TO_LEFT: aPara = "L"; break; | |||
756 | default: break; | |||
757 | } | |||
758 | rReq.AppendItem( SfxStringItem( FID_FILL_SERIES((((26000 + 200) + 20)) + 9), aPara ) ); | |||
759 | ||||
760 | switch( eFillCmd ) | |||
761 | { | |||
762 | case FILL_SIMPLE: aPara = "S"; break; | |||
763 | case FILL_LINEAR: aPara = "L"; break; | |||
764 | case FILL_GROWTH: aPara = "G"; break; | |||
765 | case FILL_DATE: aPara = "D"; break; | |||
766 | case FILL_AUTO: aPara = "A"; break; | |||
767 | default: break; | |||
768 | } | |||
769 | rReq.AppendItem( SfxStringItem( FN_PARAM_1((20000 + 1100)+60), aPara ) ); | |||
770 | ||||
771 | switch( eFillDateCmd ) | |||
772 | { | |||
773 | case FILL_DAY: aPara = "D"; break; | |||
774 | case FILL_WEEKDAY: aPara = "W"; break; | |||
775 | case FILL_MONTH: aPara = "M"; break; | |||
776 | case FILL_YEAR: aPara = "Y"; break; | |||
777 | default: break; | |||
778 | } | |||
779 | rReq.AppendItem( SfxStringItem( FN_PARAM_2((20000 + 1100)+61), aPara ) ); | |||
780 | ||||
781 | sal_uInt32 nFormatKey = pFormatter->GetStandardFormat(SvNumFormatType::NUMBER, | |||
782 | ScGlobal::eLnge ); | |||
783 | ||||
784 | pFormatter->GetOutputString( fIncVal, nFormatKey, aPara, &pColor ); | |||
785 | rReq.AppendItem( SfxStringItem( FN_PARAM_3((20000 + 1100)+62), aPara ) ); | |||
786 | ||||
787 | pFormatter->GetOutputString( fStartVal, nFormatKey, aPara, &pColor ); | |||
788 | rReq.AppendItem( SfxStringItem( FN_PARAM_4((20000 + 1100)+63), aPara ) ); | |||
789 | ||||
790 | pFormatter->GetOutputString( fMaxVal, nFormatKey, aPara, &pColor ); | |||
791 | rReq.AppendItem( SfxStringItem( FN_PARAM_5((20000 + 1100)+64), aPara ) ); | |||
792 | ||||
793 | rReq.Done(); | |||
794 | } | |||
795 | } | |||
796 | } | |||
797 | break; | |||
798 | ||||
799 | case FID_FILL_AUTO((26000 + 521) + 35): | |||
800 | { | |||
801 | SCCOL nStartCol; | |||
802 | SCROW nStartRow; | |||
803 | SCCOL nEndCol; | |||
804 | SCROW nEndRow; | |||
805 | ||||
806 | GetViewData()->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow ); | |||
807 | SCCOL nFillCol = GetViewData()->GetRefEndX(); | |||
808 | SCROW nFillRow = GetViewData()->GetRefEndY(); | |||
809 | ScDocument& rDoc = GetViewData()->GetDocument(); | |||
810 | ||||
811 | if( pReqArgs != nullptr ) | |||
812 | { | |||
813 | const SfxPoolItem* pItem; | |||
814 | ||||
815 | if( pReqArgs->HasItem( FID_FILL_AUTO((26000 + 521) + 35), &pItem ) ) | |||
816 | { | |||
817 | ScAddress aScAddress; | |||
818 | OUString aArg = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
819 | ||||
820 | if( aScAddress.Parse( aArg, rDoc, rDoc.GetAddressConvention() ) & ScRefFlags::VALID ) | |||
821 | { | |||
822 | nFillRow = aScAddress.Row(); | |||
823 | nFillCol = aScAddress.Col(); | |||
824 | } | |||
825 | } | |||
826 | ||||
827 | SCTAB nStartTab, nEndTab; | |||
828 | GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab, | |||
829 | nEndCol,nEndRow,nEndTab ); | |||
830 | } | |||
831 | else // call via mouse | |||
832 | { | |||
833 | // not in a merged cell | |||
834 | ||||
835 | if ( nStartCol == nEndCol && nStartRow == nEndRow ) | |||
836 | { | |||
837 | SCCOL nMergeCol = nStartCol; | |||
838 | SCROW nMergeRow = nStartRow; | |||
839 | if ( GetViewData()->GetDocument().ExtendMerge( | |||
840 | nStartCol, nStartRow, nMergeCol, nMergeRow, | |||
841 | GetViewData()->GetTabNo() ) ) | |||
842 | { | |||
843 | if ( nFillCol >= nStartCol && nFillCol <= nMergeCol && nFillRow == nStartRow ) | |||
844 | nFillCol = nStartCol; | |||
845 | if ( nFillRow >= nStartRow && nFillRow <= nMergeRow && nFillCol == nStartCol ) | |||
846 | nFillRow = nStartRow; | |||
847 | } | |||
848 | } | |||
849 | } | |||
850 | ||||
851 | if ( nFillCol != nEndCol || nFillRow != nEndRow ) | |||
852 | { | |||
853 | if ( nFillCol==nEndCol || nFillRow==nEndRow ) | |||
854 | { | |||
855 | FillDir eDir = FILL_TO_BOTTOM; | |||
856 | SCCOLROW nCount = 0; | |||
857 | ||||
858 | if ( nFillCol==nEndCol ) | |||
859 | { | |||
860 | if ( nFillRow > nEndRow ) | |||
861 | { | |||
862 | eDir = FILL_TO_BOTTOM; | |||
863 | nCount = nFillRow - nEndRow; | |||
864 | } | |||
865 | else if ( nFillRow < nStartRow ) | |||
866 | { | |||
867 | eDir = FILL_TO_TOP; | |||
868 | nCount = nStartRow - nFillRow; | |||
869 | } | |||
870 | } | |||
871 | else | |||
872 | { | |||
873 | if ( nFillCol > nEndCol ) | |||
874 | { | |||
875 | eDir = FILL_TO_RIGHT; | |||
876 | nCount = nFillCol - nEndCol; | |||
877 | } | |||
878 | else if ( nFillCol < nStartCol ) | |||
879 | { | |||
880 | eDir = FILL_TO_LEFT; | |||
881 | nCount = nStartCol - nFillCol; | |||
882 | } | |||
883 | } | |||
884 | ||||
885 | if ( nCount != 0) | |||
886 | { | |||
887 | pTabViewShell->FillAuto( eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount ); | |||
888 | ||||
889 | if( ! rReq.IsAPI() ) | |||
890 | { | |||
891 | ScAddress aAdr( nFillCol, nFillRow, 0 ); | |||
892 | OUString aAdrStr(aAdr.Format(ScRefFlags::RANGE_ABS, &rDoc, rDoc.GetAddressConvention())); | |||
893 | ||||
894 | rReq.AppendItem( SfxStringItem( FID_FILL_AUTO((26000 + 521) + 35), aAdrStr ) ); | |||
895 | rReq.Done(); | |||
896 | } | |||
897 | } | |||
898 | ||||
899 | } | |||
900 | else | |||
901 | { | |||
902 | OSL_FAIL( "Direction not unique for autofill" )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/cellsh1.cxx" ":" "902" ": "), "%s", "Direction not unique for autofill"); } } while (false); | |||
903 | } | |||
904 | } | |||
905 | } | |||
906 | break; | |||
907 | case FID_FILL_SINGLE_EDIT((((26000 + 200) + 20)) + 10): | |||
908 | ExecuteFillSingleEdit(); | |||
909 | break; | |||
910 | case SID_RANDOM_NUMBER_GENERATOR_DIALOG((26000 + 100) + 70): | |||
911 | { | |||
912 | sal_uInt16 nId = ScRandomNumberGeneratorDialogWrapper::GetChildWindowId(); | |||
913 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
914 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
915 | ||||
916 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
917 | ||||
918 | } | |||
919 | break; | |||
920 | case SID_SAMPLING_DIALOG((26000 + 100) + 71): | |||
921 | { | |||
922 | sal_uInt16 nId = ScSamplingDialogWrapper::GetChildWindowId(); | |||
923 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
924 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
925 | ||||
926 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
927 | } | |||
928 | break; | |||
929 | case SID_DESCRIPTIVE_STATISTICS_DIALOG((26000 + 100) + 72): | |||
930 | { | |||
931 | sal_uInt16 nId = ScDescriptiveStatisticsDialogWrapper::GetChildWindowId(); | |||
932 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
933 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
934 | ||||
935 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
936 | } | |||
937 | break; | |||
938 | case SID_ANALYSIS_OF_VARIANCE_DIALOG((26000 + 100) + 73): | |||
939 | { | |||
940 | sal_uInt16 nId = ScAnalysisOfVarianceDialogWrapper::GetChildWindowId(); | |||
941 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
942 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
943 | ||||
944 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
945 | } | |||
946 | break; | |||
947 | case SID_CORRELATION_DIALOG((26000 + 100) + 74): | |||
948 | { | |||
949 | sal_uInt16 nId = ScCorrelationDialogWrapper::GetChildWindowId(); | |||
950 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
951 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
952 | ||||
953 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
954 | } | |||
955 | break; | |||
956 | case SID_COVARIANCE_DIALOG((26000 + 100) + 75): | |||
957 | { | |||
958 | sal_uInt16 nId = ScCovarianceDialogWrapper::GetChildWindowId(); | |||
959 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
960 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
961 | ||||
962 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
963 | } | |||
964 | break; | |||
965 | case SID_EXPONENTIAL_SMOOTHING_DIALOG((26000 + 100) + 76): | |||
966 | { | |||
967 | sal_uInt16 nId = ScExponentialSmoothingDialogWrapper::GetChildWindowId(); | |||
968 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
969 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
970 | ||||
971 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
972 | } | |||
973 | break; | |||
974 | case SID_MOVING_AVERAGE_DIALOG((26000 + 100) + 77): | |||
975 | { | |||
976 | sal_uInt16 nId = ScMovingAverageDialogWrapper::GetChildWindowId(); | |||
977 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
978 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
979 | ||||
980 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
981 | } | |||
982 | break; | |||
983 | case SID_REGRESSION_DIALOG((26000 + 100) + 78): | |||
984 | { | |||
985 | sal_uInt16 nId = ScRegressionDialogWrapper::GetChildWindowId(); | |||
986 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
987 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
988 | ||||
989 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
990 | } | |||
991 | break; | |||
992 | case SID_TTEST_DIALOG((26000 + 100) + 79): | |||
993 | { | |||
994 | sal_uInt16 nId = ScTTestDialogWrapper::GetChildWindowId(); | |||
995 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
996 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
997 | ||||
998 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
999 | ||||
1000 | } | |||
1001 | break; | |||
1002 | case SID_FTEST_DIALOG((26000 + 100) + 80): | |||
1003 | { | |||
1004 | sal_uInt16 nId = ScFTestDialogWrapper::GetChildWindowId(); | |||
1005 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
1006 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
1007 | ||||
1008 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
1009 | ||||
1010 | } | |||
1011 | break; | |||
1012 | case SID_ZTEST_DIALOG((26000 + 100) + 81): | |||
1013 | { | |||
1014 | sal_uInt16 nId = ScZTestDialogWrapper::GetChildWindowId(); | |||
1015 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
1016 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
1017 | ||||
1018 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
1019 | ||||
1020 | } | |||
1021 | break; | |||
1022 | case SID_CHI_SQUARE_TEST_DIALOG((26000 + 100) + 82): | |||
1023 | { | |||
1024 | sal_uInt16 nId = ScChiSquareTestDialogWrapper::GetChildWindowId(); | |||
1025 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
1026 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
1027 | ||||
1028 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
1029 | ||||
1030 | } | |||
1031 | break; | |||
1032 | case SID_FOURIER_ANALYSIS_DIALOG((26000 + 100) + 88): | |||
1033 | { | |||
1034 | sal_uInt16 nId = ScFourierAnalysisDialogWrapper::GetChildWindowId(); | |||
1035 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
1036 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
1037 | ||||
1038 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
1039 | ||||
1040 | } | |||
1041 | break; | |||
1042 | case SID_SEARCH_RESULTS_DIALOG((26000 + 100) + 83): | |||
1043 | { | |||
1044 | const SfxPoolItem* pItem = nullptr; | |||
1045 | if (pReqArgs && pReqArgs->HasItem(SID_SEARCH_RESULTS_DIALOG((26000 + 100) + 83), &pItem)) | |||
1046 | { | |||
1047 | bool bVisible = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | |||
1048 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
1049 | // The window ID should equal the slot ID, but not a biggie if it wasn't. | |||
1050 | sal_uInt16 nId = sc::SearchResultsDlgWrapper::GetChildWindowId(); | |||
1051 | pViewFrm->SetChildWindow(nId, bVisible, false); | |||
1052 | } | |||
1053 | rReq.Done(); | |||
1054 | } | |||
1055 | break; | |||
1056 | ||||
1057 | // disposal (Outlines) | |||
1058 | // SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl) | |||
1059 | ||||
1060 | case SID_OUTLINE_HIDE((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 25): | |||
1061 | if ( GetViewData()->GetDocument().GetDPAtCursor( GetViewData()->GetCurX(), | |||
1062 | GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) ) | |||
1063 | pTabViewShell->SetDataPilotDetails( false ); | |||
1064 | else | |||
1065 | pTabViewShell->HideMarkedOutlines(); | |||
1066 | rReq.Done(); | |||
1067 | break; | |||
1068 | ||||
1069 | case SID_OUTLINE_SHOW((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 26): | |||
1070 | { | |||
1071 | ScDPObject* pDPObj = GetViewData()->GetDocument().GetDPAtCursor( GetViewData()->GetCurX(), | |||
1072 | GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); | |||
1073 | if ( pDPObj ) | |||
1074 | { | |||
1075 | Sequence<sheet::DataPilotFieldFilter> aFilters; | |||
1076 | css::sheet::DataPilotFieldOrientation nOrientation; | |||
1077 | if ( pTabViewShell->HasSelectionForDrillDown( nOrientation ) ) | |||
1078 | { | |||
1079 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
1080 | ScopedVclPtr<AbstractScDPShowDetailDlg> pDlg( pFact->CreateScDPShowDetailDlg( | |||
1081 | pTabViewShell->GetFrameWeld(), *pDPObj, nOrientation ) ); | |||
1082 | if ( pDlg->Execute() == RET_OK ) | |||
1083 | { | |||
1084 | OUString aNewDimName( pDlg->GetDimensionName() ); | |||
1085 | pTabViewShell->SetDataPilotDetails( true, &aNewDimName ); | |||
1086 | } | |||
1087 | } | |||
1088 | else if ( !pDPObj->IsServiceData() && | |||
1089 | pDPObj->GetDataFieldPositionData( | |||
1090 | ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ), | |||
1091 | aFilters ) ) | |||
1092 | pTabViewShell->ShowDataPilotSourceData( *pDPObj, aFilters ); | |||
1093 | else | |||
1094 | pTabViewShell->SetDataPilotDetails(true); | |||
1095 | } | |||
1096 | else | |||
1097 | pTabViewShell->ShowMarkedOutlines(); | |||
1098 | rReq.Done(); | |||
1099 | } | |||
1100 | break; | |||
1101 | ||||
1102 | case SID_OUTLINE_MAKE((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 27): | |||
1103 | { | |||
1104 | bool bColumns = false; | |||
1105 | bool bOk = true; | |||
1106 | ||||
1107 | if ( GetViewData()->GetDocument().GetDPAtCursor( GetViewData()->GetCurX(), | |||
1108 | GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) ) | |||
1109 | { | |||
1110 | ScDPNumGroupInfo aNumInfo; | |||
1111 | aNumInfo.mbEnable = true; | |||
1112 | aNumInfo.mbAutoStart = true; | |||
1113 | aNumInfo.mbAutoEnd = true; | |||
1114 | sal_Int32 nParts = 0; | |||
1115 | if ( pTabViewShell->HasSelectionForDateGroup( aNumInfo, nParts ) ) | |||
1116 | { | |||
1117 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
1118 | const Date& rNullDate( GetViewData()->GetDocument().GetFormatTable()->GetNullDate() ); | |||
1119 | ScopedVclPtr<AbstractScDPDateGroupDlg> pDlg( pFact->CreateScDPDateGroupDlg( | |||
1120 | pTabViewShell->GetFrameWeld(), | |||
1121 | aNumInfo, nParts, rNullDate ) ); | |||
1122 | if( pDlg->Execute() == RET_OK ) | |||
1123 | { | |||
1124 | aNumInfo = pDlg->GetGroupInfo(); | |||
1125 | pTabViewShell->DateGroupDataPilot( aNumInfo, pDlg->GetDatePart() ); | |||
1126 | } | |||
1127 | } | |||
1128 | else if ( pTabViewShell->HasSelectionForNumGroup( aNumInfo ) ) | |||
1129 | { | |||
1130 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
1131 | ScopedVclPtr<AbstractScDPNumGroupDlg> pDlg( pFact->CreateScDPNumGroupDlg( | |||
1132 | pTabViewShell->GetFrameWeld(), aNumInfo ) ); | |||
1133 | if( pDlg->Execute() == RET_OK ) | |||
1134 | pTabViewShell->NumGroupDataPilot( pDlg->GetGroupInfo() ); | |||
1135 | } | |||
1136 | else | |||
1137 | pTabViewShell->GroupDataPilot(); | |||
1138 | ||||
1139 | bOk = false; | |||
1140 | } | |||
1141 | else if( pReqArgs != nullptr ) | |||
1142 | { | |||
1143 | const SfxPoolItem* pItem; | |||
1144 | bOk = false; | |||
1145 | ||||
1146 | if( pReqArgs->HasItem( SID_OUTLINE_MAKE((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 27), &pItem ) ) | |||
1147 | { | |||
1148 | OUString aCol = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
1149 | aCol = aCol.toAsciiUpperCase(); | |||
1150 | ||||
1151 | switch( aCol[0] ) | |||
1152 | { | |||
1153 | case 'R': bColumns=false; bOk = true;break; | |||
1154 | case 'C': bColumns=true; bOk = true;break; | |||
1155 | } | |||
1156 | } | |||
1157 | } | |||
1158 | else // Dialog, when not whole rows/columns are marked | |||
1159 | { | |||
1160 | if ( GetViewData()->SimpleColMarked() && !GetViewData()->SimpleRowMarked() ) | |||
1161 | bColumns = true; | |||
1162 | else if ( !GetViewData()->SimpleColMarked() && GetViewData()->SimpleRowMarked() ) | |||
1163 | bColumns = false; | |||
1164 | else | |||
1165 | { | |||
1166 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
1167 | ||||
1168 | VclPtr<AbstractScGroupDlg> pDlg(pFact->CreateAbstractScGroupDlg(pTabViewShell->GetFrameWeld())); | |||
1169 | ||||
1170 | pDlg->StartExecuteAsync( | |||
1171 | [pDlg, pTabViewShell] (sal_Int32 nResult) { | |||
1172 | if( RET_OK == nResult ) | |||
1173 | { | |||
1174 | bool bColumn = pDlg->GetColsChecked(); | |||
1175 | pTabViewShell->MakeOutline( bColumn ); | |||
1176 | } | |||
1177 | pDlg->disposeOnce(); | |||
1178 | } | |||
1179 | ); | |||
1180 | ||||
1181 | bOk = false; | |||
1182 | } | |||
1183 | } | |||
1184 | if (bOk) | |||
1185 | { | |||
1186 | pTabViewShell->MakeOutline( bColumns ); | |||
1187 | ||||
1188 | if( ! rReq.IsAPI() ) | |||
1189 | { | |||
1190 | OUString aCol = bColumns ? OUString('C') : OUString('R'); | |||
1191 | rReq.AppendItem( SfxStringItem( SID_OUTLINE_MAKE((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 27), aCol ) ); | |||
1192 | rReq.Done(); | |||
1193 | } | |||
1194 | } | |||
1195 | } | |||
1196 | break; | |||
1197 | ||||
1198 | case SID_OUTLINE_REMOVE((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 28): | |||
1199 | { | |||
1200 | bool bColumns = false; | |||
1201 | bool bOk = true; | |||
1202 | ||||
1203 | if ( GetViewData()->GetDocument().GetDPAtCursor( GetViewData()->GetCurX(), | |||
1204 | GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) ) | |||
1205 | { | |||
1206 | pTabViewShell->UngroupDataPilot(); | |||
1207 | bOk = false; | |||
1208 | } | |||
1209 | else if( pReqArgs != nullptr ) | |||
1210 | { | |||
1211 | const SfxPoolItem* pItem; | |||
1212 | bOk = false; | |||
1213 | ||||
1214 | if( pReqArgs->HasItem( SID_OUTLINE_REMOVE((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 28), &pItem ) ) | |||
1215 | { | |||
1216 | OUString aCol = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
1217 | aCol = aCol.toAsciiUpperCase(); | |||
1218 | ||||
1219 | switch (aCol[0]) | |||
1220 | { | |||
1221 | case 'R': bColumns=false; bOk = true;break; | |||
1222 | case 'C': bColumns=true; bOk = true;break; | |||
1223 | } | |||
1224 | } | |||
1225 | } | |||
1226 | else // Dialog only when removal for rows and columns is possible | |||
1227 | { | |||
1228 | bool bColPoss, bRowPoss; | |||
1229 | pTabViewShell->TestRemoveOutline( bColPoss, bRowPoss ); | |||
1230 | // TODO: handle this case in LOK too | |||
1231 | if ( bColPoss && bRowPoss && !comphelper::LibreOfficeKit::isActive() ) | |||
1232 | { | |||
1233 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
1234 | ||||
1235 | VclPtr<AbstractScGroupDlg> pDlg(pFact->CreateAbstractScGroupDlg(pTabViewShell->GetFrameWeld(), true)); | |||
1236 | ||||
1237 | pDlg->StartExecuteAsync( | |||
1238 | [pDlg, pTabViewShell] (sal_Int32 nResult) { | |||
1239 | if( RET_OK == nResult ) | |||
1240 | { | |||
1241 | bool bColumn = pDlg->GetColsChecked(); | |||
1242 | pTabViewShell->RemoveOutline( bColumn ); | |||
1243 | } | |||
1244 | pDlg->disposeOnce(); | |||
1245 | } | |||
1246 | ); | |||
1247 | ||||
1248 | bOk = false; | |||
1249 | } | |||
1250 | else if ( bColPoss ) | |||
1251 | bColumns = true; | |||
1252 | else if ( bRowPoss ) | |||
1253 | bColumns = false; | |||
1254 | else | |||
1255 | bOk = false; | |||
1256 | } | |||
1257 | if (bOk) | |||
1258 | { | |||
1259 | pTabViewShell->RemoveOutline( bColumns ); | |||
1260 | ||||
1261 | if( ! rReq.IsAPI() ) | |||
1262 | { | |||
1263 | OUString aCol = bColumns ? OUString('C') : OUString('R'); | |||
1264 | rReq.AppendItem( SfxStringItem( SID_OUTLINE_REMOVE((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 28), aCol ) ); | |||
1265 | rReq.Done(); | |||
1266 | } | |||
1267 | } | |||
1268 | } | |||
1269 | break; | |||
1270 | ||||
1271 | // Clipboard | |||
1272 | ||||
1273 | case SID_COPY(5000 + 711): // for graphs in DrawShell | |||
1274 | { | |||
1275 | weld::WaitObject aWait( GetViewData()->GetDialogParent() ); | |||
1276 | pTabViewShell->CopyToClip( nullptr, false, false, true ); | |||
1277 | rReq.Done(); | |||
1278 | GetViewData()->SetPasteMode( ScPasteFlags::Mode | ScPasteFlags::Border ); | |||
1279 | pTabViewShell->ShowCursor(); | |||
1280 | pTabViewShell->UpdateCopySourceOverlay(); | |||
1281 | } | |||
1282 | break; | |||
1283 | ||||
1284 | case SID_CUT(5000 + 710): // for graphs in DrawShell | |||
1285 | { | |||
1286 | weld::WaitObject aWait( GetViewData()->GetDialogParent() ); | |||
1287 | pTabViewShell->CutToClip(); | |||
1288 | rReq.Done(); | |||
1289 | GetViewData()->SetPasteMode( ScPasteFlags::Mode | ScPasteFlags::Border ); | |||
1290 | pTabViewShell->ShowCursor(); | |||
1291 | pTabViewShell->UpdateCopySourceOverlay(); | |||
1292 | } | |||
1293 | break; | |||
1294 | ||||
1295 | case SID_PASTE(5000 + 712): | |||
1296 | { | |||
1297 | ScClipUtil::PasteFromClipboard ( GetViewData(), pTabViewShell, true ); | |||
1298 | rReq.Done(); | |||
1299 | } | |||
1300 | break; | |||
1301 | ||||
1302 | case SID_CLIPBOARD_FORMAT_ITEMS(5000 + 312): | |||
1303 | { | |||
1304 | weld::WaitObject aWait( GetViewData()->GetDialogParent() ); | |||
1305 | ||||
1306 | SotClipboardFormatId nFormat = SotClipboardFormatId::NONE; | |||
1307 | const SfxPoolItem* pItem; | |||
1308 | if ( pReqArgs && | |||
1309 | pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET && | |||
1310 | dynamic_cast<const SfxUInt32Item*>( pItem) != nullptr ) | |||
1311 | { | |||
1312 | nFormat = static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pItem)->GetValue()); | |||
1313 | } | |||
1314 | ||||
1315 | if ( nFormat != SotClipboardFormatId::NONE ) | |||
1316 | { | |||
1317 | css::uno::Reference<css::datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(GetViewData()->GetActiveWin())); | |||
1318 | bool bCells = ( ScTransferObj::GetOwnClipboard(xTransferable) != nullptr ); | |||
1319 | bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr ); | |||
1320 | bool bOle = ( nFormat == SotClipboardFormatId::EMBED_SOURCE ); | |||
1321 | ||||
1322 | if ( bCells && bOle ) | |||
1323 | pTabViewShell->PasteFromSystem(); | |||
1324 | else if ( bDraw && bOle ) | |||
1325 | pTabViewShell->PasteDraw(); | |||
1326 | else | |||
1327 | pTabViewShell->PasteFromSystem(nFormat); | |||
1328 | } | |||
1329 | //?else | |||
1330 | //? pTabViewShell->PasteFromSystem(); | |||
1331 | ||||
1332 | rReq.Done(); | |||
1333 | } | |||
1334 | pTabViewShell->CellContentChanged(); | |||
1335 | break; | |||
1336 | ||||
1337 | case FID_INS_CELL_CONTENTS((((((((26000 + 200) + 20)) + 20)) + 20)) + 5): | |||
1338 | { | |||
1339 | ScDocument& rDoc = GetViewData()->GetDocument(); | |||
1340 | bool bOtherDoc = !rDoc.IsClipboardSource(); | |||
1341 | // keep a reference in case the clipboard is changed during dialog or PasteFromClip | |||
1342 | const ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(GetViewData()->GetActiveWin())); | |||
1343 | if ( pOwnClip ) | |||
1344 | { | |||
1345 | InsertDeleteFlags nFlags = InsertDeleteFlags::NONE; | |||
1346 | ScPasteFunc nFunction = ScPasteFunc::NONE; | |||
1347 | InsCellCmd eMoveMode = INS_NONE; | |||
1348 | bool bSkipEmpty = false; | |||
1349 | bool bTranspose = false; | |||
1350 | bool bAsLink = false; | |||
1351 | ||||
1352 | if ( pReqArgs!=nullptr && pTabViewShell->SelectionEditable() ) | |||
1353 | { | |||
1354 | const SfxPoolItem* pItem; | |||
1355 | OUString aFlags('A'); | |||
1356 | ||||
1357 | if( pReqArgs->HasItem( FID_INS_CELL_CONTENTS((((((((26000 + 200) + 20)) + 20)) + 20)) + 5), &pItem ) ) | |||
1358 | aFlags = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
1359 | ||||
1360 | nFlags |= FlagsFromString(aFlags); | |||
1361 | ||||
1362 | const SfxUInt16Item* pFuncItem = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1((20000 + 1100)+60)); | |||
1363 | const SfxBoolItem* pSkipItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_2((20000 + 1100)+61)); | |||
1364 | const SfxBoolItem* pTransposeItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_3((20000 + 1100)+62)); | |||
1365 | const SfxBoolItem* pLinkItem = rReq.GetArg<SfxBoolItem>(FN_PARAM_4((20000 + 1100)+63)); | |||
1366 | const SfxInt16Item* pMoveItem = rReq.GetArg<SfxInt16Item>(FN_PARAM_5((20000 + 1100)+64)); | |||
1367 | if ( pFuncItem ) | |||
1368 | nFunction = static_cast<ScPasteFunc>(pFuncItem->GetValue()); | |||
1369 | if ( pSkipItem ) | |||
1370 | bSkipEmpty = pSkipItem->GetValue(); | |||
1371 | if ( pTransposeItem ) | |||
1372 | bTranspose = pTransposeItem->GetValue(); | |||
1373 | if ( pLinkItem ) | |||
1374 | bAsLink = pLinkItem->GetValue(); | |||
1375 | if ( pMoveItem ) | |||
1376 | eMoveMode = static_cast<InsCellCmd>(pMoveItem->GetValue()); | |||
1377 | } | |||
1378 | else | |||
1379 | { | |||
1380 | ScEditableTester aTester( pTabViewShell ); | |||
1381 | if (aTester.IsEditable()) | |||
1382 | { | |||
1383 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
1384 | ||||
1385 | ScopedVclPtr<AbstractScInsertContentsDlg> pDlg(pFact->CreateScInsertContentsDlg(pTabViewShell->GetFrameWeld())); | |||
1386 | pDlg->SetOtherDoc( bOtherDoc ); | |||
1387 | // if ChangeTrack MoveMode disable | |||
1388 | pDlg->SetChangeTrack( rDoc.GetChangeTrack() != nullptr ); | |||
1389 | // fdo#56098 disable shift if necessary | |||
1390 | if (!bOtherDoc) | |||
1391 | { | |||
1392 | ScViewData* pData = GetViewData(); | |||
1393 | if ( pData->GetMarkData().GetTableSelect( pData->GetTabNo() ) ) | |||
1394 | { | |||
1395 | SCCOL nStartX, nEndX, nClipStartX, nClipSizeX, nRangeSizeX; | |||
1396 | SCROW nStartY, nEndY, nClipStartY, nClipSizeY, nRangeSizeY; | |||
1397 | SCTAB nStartTab, nEndTab; | |||
1398 | pOwnClip->GetDocument()->GetClipStart( nClipStartX, nClipStartY ); | |||
1399 | pOwnClip->GetDocument()->GetClipArea( nClipSizeX, nClipSizeY, true ); | |||
1400 | ||||
1401 | if ( pData->GetSimpleArea( nStartX, nStartY, nStartTab, | |||
1402 | nEndX, nEndY, nEndTab ) != SC_MARK_SIMPLE || | |||
1403 | nStartTab != nEndTab ) | |||
1404 | { | |||
1405 | // the destination is not a simple range, | |||
1406 | // assume the destination as the current cell | |||
1407 | nStartX = nEndX = pData->GetCurX(); | |||
1408 | nStartY = nEndY = pData->GetCurY(); | |||
1409 | nStartTab = pData->GetTabNo(); | |||
1410 | } | |||
1411 | // we now have clip- and range dimensions | |||
1412 | // the size of the destination area is the larger of the two | |||
1413 | nRangeSizeX = nClipSizeX >= nEndX - nStartX ? nClipSizeX : nEndX - nStartX; | |||
1414 | nRangeSizeY = nClipSizeY >= nEndY - nStartY ? nClipSizeY : nEndY - nStartY; | |||
1415 | // When the source and destination areas intersect things may go wrong, | |||
1416 | // especially if the area contains references. This may produce data loss | |||
1417 | // (e.g. formulas that get wrong references), this scenario _must_ be avoided. | |||
1418 | ScRange aSource( nClipStartX, nClipStartY, nStartTab, | |||
1419 | nClipStartX + nClipSizeX, nClipStartY + nClipSizeY, nStartTab ); | |||
1420 | ScRange aDest( nStartX, nStartY, nStartTab, | |||
1421 | nStartX + nRangeSizeX, nStartY + nRangeSizeY, nStartTab ); | |||
1422 | if ( pOwnClip->GetDocument()->IsCutMode() && aSource.Intersects( aDest ) ) | |||
1423 | pDlg->SetCellShiftDisabled( CellShiftDisabledFlags::Down | CellShiftDisabledFlags::Right ); | |||
1424 | else | |||
1425 | { | |||
1426 | //no conflict with intersecting ranges, | |||
1427 | //check if paste plus shift will fit on sheet | |||
1428 | //and disable shift-option if no fit | |||
1429 | CellShiftDisabledFlags nDisableShiftX = CellShiftDisabledFlags::NONE; | |||
1430 | CellShiftDisabledFlags nDisableShiftY = CellShiftDisabledFlags::NONE; | |||
1431 | ||||
1432 | //check if horizontal shift will fit | |||
1433 | if ( !pData->GetDocument().IsBlockEmpty( nStartTab, | |||
1434 | rDoc.MaxCol() - nRangeSizeX, nStartY, | |||
1435 | rDoc.MaxCol(), nStartY + nRangeSizeY ) ) | |||
1436 | nDisableShiftX = CellShiftDisabledFlags::Right; | |||
1437 | ||||
1438 | //check if vertical shift will fit | |||
1439 | if ( !pData->GetDocument().IsBlockEmpty( nStartTab, | |||
1440 | nStartX, rDoc.MaxRow() - nRangeSizeY, | |||
1441 | nStartX + nRangeSizeX, rDoc.MaxRow() ) ) | |||
1442 | nDisableShiftY = CellShiftDisabledFlags::Down; | |||
1443 | ||||
1444 | if ( nDisableShiftX != CellShiftDisabledFlags::NONE || nDisableShiftY != CellShiftDisabledFlags::NONE) | |||
1445 | pDlg->SetCellShiftDisabled( nDisableShiftX | nDisableShiftY ); | |||
1446 | } | |||
1447 | } | |||
1448 | } | |||
1449 | if (pDlg->Execute() == RET_OK) | |||
1450 | { | |||
1451 | nFlags = pDlg->GetInsContentsCmdBits(); | |||
1452 | nFunction = pDlg->GetFormulaCmdBits(); | |||
1453 | bSkipEmpty = pDlg->IsSkipEmptyCells(); | |||
1454 | bTranspose = pDlg->IsTranspose(); | |||
1455 | bAsLink = pDlg->IsLink(); | |||
1456 | eMoveMode = pDlg->GetMoveMode(); | |||
1457 | } | |||
1458 | } | |||
1459 | else | |||
1460 | pTabViewShell->ErrorMessage(aTester.GetMessageId()); | |||
1461 | } | |||
1462 | ||||
1463 | if( nFlags != InsertDeleteFlags::NONE ) | |||
1464 | { | |||
1465 | { | |||
1466 | weld::WaitObject aWait( GetViewData()->GetDialogParent() ); | |||
1467 | if ( bAsLink && bOtherDoc ) | |||
1468 | pTabViewShell->PasteFromSystem(SotClipboardFormatId::LINK); // DDE insert | |||
1469 | else | |||
1470 | { | |||
1471 | pTabViewShell->PasteFromClip( nFlags, pOwnClip->GetDocument(), | |||
1472 | nFunction, bSkipEmpty, bTranspose, bAsLink, | |||
1473 | eMoveMode, InsertDeleteFlags::NONE, true ); // allow warning dialog | |||
1474 | } | |||
1475 | } | |||
1476 | ||||
1477 | if( !pReqArgs ) | |||
1478 | { | |||
1479 | OUString aFlags = FlagsToString( nFlags ); | |||
1480 | ||||
1481 | rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS((((((((26000 + 200) + 20)) + 20)) + 20)) + 5), aFlags ) ); | |||
1482 | rReq.AppendItem( SfxBoolItem( FN_PARAM_2((20000 + 1100)+61), bSkipEmpty ) ); | |||
1483 | rReq.AppendItem( SfxBoolItem( FN_PARAM_3((20000 + 1100)+62), bTranspose ) ); | |||
1484 | rReq.AppendItem( SfxBoolItem( FN_PARAM_4((20000 + 1100)+63), bAsLink ) ); | |||
1485 | rReq.AppendItem( SfxUInt16Item( FN_PARAM_1((20000 + 1100)+60), static_cast<sal_uInt16>(nFunction) ) ); | |||
1486 | rReq.AppendItem( SfxInt16Item( FN_PARAM_5((20000 + 1100)+64), static_cast<sal_Int16>(eMoveMode) ) ); | |||
1487 | rReq.Done(); | |||
1488 | } | |||
1489 | } | |||
1490 | } | |||
1491 | } | |||
1492 | pTabViewShell->CellContentChanged(); // => PasteFromXXX ??? | |||
1493 | break; | |||
1494 | case SID_PASTE_ONLY_VALUE(5000 + 804): | |||
1495 | case SID_PASTE_ONLY_TEXT(5000 + 802): | |||
1496 | case SID_PASTE_ONLY_FORMULA(5000 + 803): | |||
1497 | { | |||
1498 | if ( ScTransferObj::GetOwnClipboard(ScTabViewShell::GetClipData(GetViewData()->GetActiveWin())) ) // own cell data | |||
1499 | { | |||
1500 | rReq.SetSlot( FID_INS_CELL_CONTENTS((((((((26000 + 200) + 20)) + 20)) + 20)) + 5) ); | |||
1501 | OUString aFlags; | |||
1502 | if ( nSlot == SID_PASTE_ONLY_VALUE(5000 + 804) ) | |||
1503 | aFlags = "V"; | |||
1504 | else if ( nSlot == SID_PASTE_ONLY_TEXT(5000 + 802) ) | |||
1505 | aFlags = "S"; | |||
1506 | else | |||
1507 | aFlags = "F"; | |||
1508 | rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS((((((((26000 + 200) + 20)) + 20)) + 20)) + 5), aFlags ) ); | |||
1509 | ExecuteSlot( rReq, GetInterface() ); | |||
1510 | rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success | |||
1511 | pTabViewShell->CellContentChanged(); | |||
1512 | } | |||
1513 | else | |||
1514 | rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail | |||
1515 | break; | |||
1516 | } | |||
1517 | case SID_PASTE_TEXTIMPORT_DIALOG(5000 + 805): | |||
1518 | { | |||
1519 | vcl::Window* pWin = GetViewData()->GetActiveWin(); | |||
1520 | TransferableDataHelper aDataHelper( | |||
1521 | TransferableDataHelper::CreateFromSystemClipboard(pWin)); | |||
1522 | const uno::Reference<datatransfer::XTransferable>& xTransferable | |||
1523 | = aDataHelper.GetTransferable(); | |||
1524 | SotClipboardFormatId format = SotClipboardFormatId::STRING; | |||
1525 | bool bSuccess = false; | |||
1526 | if (xTransferable.is() && HasClipboardFormat(format)) | |||
1527 | { | |||
1528 | OUString sStrBuffer; | |||
1529 | bSuccess = aDataHelper.GetString(format, sStrBuffer); | |||
1530 | if (bSuccess) | |||
1531 | { | |||
1532 | auto pStrm = std::make_shared<ScImportStringStream>(sStrBuffer); | |||
1533 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
1534 | VclPtr<AbstractScImportAsciiDlg> pDlg(pFact->CreateScImportAsciiDlg( | |||
1535 | pWin ? pWin->GetFrameWeld() : nullptr, OUString(), pStrm.get(), SC_PASTETEXT)); | |||
1536 | ScRange aRange; | |||
1537 | SCCOL nPosX = 0; | |||
1538 | SCROW nPosY = 0; | |||
1539 | if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE) | |||
1540 | { | |||
1541 | nPosX = aRange.aStart.Col(); | |||
1542 | nPosY = aRange.aStart.Row(); | |||
1543 | } | |||
1544 | else | |||
1545 | { | |||
1546 | nPosX = GetViewData()->GetCurX(); | |||
1547 | nPosY = GetViewData()->GetCurY(); | |||
1548 | } | |||
1549 | ScAddress aCellPos(nPosX, nPosY, GetViewData()->GetTabNo()); | |||
1550 | auto pObj = std::make_shared<ScImportExport>(GetViewData()->GetDocument(), aCellPos); | |||
1551 | pObj->SetOverwriting(true); | |||
1552 | if (pDlg->Execute()) { | |||
1553 | ScAsciiOptions aOptions; | |||
1554 | pDlg->GetOptions(aOptions); | |||
1555 | pDlg->SaveParameters(); | |||
1556 | pObj->SetExtOptions(aOptions); | |||
1557 | pObj->ImportString(sStrBuffer, format); | |||
1558 | } | |||
1559 | pDlg->disposeOnce(); | |||
1560 | rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success, 0 = fail | |||
1561 | rReq.Done(); | |||
1562 | } | |||
1563 | } | |||
1564 | if (!bSuccess) | |||
1565 | { | |||
1566 | rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail | |||
1567 | rReq.Ignore(); | |||
1568 | } | |||
1569 | } | |||
1570 | break; | |||
1571 | case SID_PASTE_SPECIAL(5000 + 311): | |||
1572 | // differentiate between own cell data and draw objects/external data | |||
1573 | // this makes FID_INS_CELL_CONTENTS superfluous | |||
1574 | { | |||
1575 | vcl::Window* pWin = GetViewData()->GetActiveWin(); | |||
1576 | css::uno::Reference<css::datatransfer::XTransferable2> xTransferable(ScTabViewShell::GetClipData(pWin)); | |||
1577 | ||||
1578 | // Clipboard-ID given as parameter? Basic "PasteSpecial(Format)" | |||
1579 | const SfxPoolItem* pItem=nullptr; | |||
1580 | if ( pReqArgs && | |||
1581 | pReqArgs->GetItemState(nSlot, true, &pItem) == SfxItemState::SET && | |||
1582 | dynamic_cast<const SfxUInt32Item*>( pItem) != nullptr ) | |||
1583 | { | |||
1584 | SotClipboardFormatId nFormat = static_cast<SotClipboardFormatId>(static_cast<const SfxUInt32Item*>(pItem)->GetValue()); | |||
1585 | bool bRet=true; | |||
1586 | { | |||
1587 | weld::WaitObject aWait( GetViewData()->GetDialogParent() ); | |||
1588 | bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr ); | |||
1589 | if ( bDraw && nFormat == SotClipboardFormatId::EMBED_SOURCE ) | |||
1590 | pTabViewShell->PasteDraw(); | |||
1591 | else | |||
1592 | bRet = pTabViewShell->PasteFromSystem(nFormat, true); // TRUE: no error messages | |||
1593 | } | |||
1594 | ||||
1595 | if ( bRet ) | |||
1596 | { | |||
1597 | rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success, 0 = fail | |||
1598 | rReq.Done(); | |||
1599 | } | |||
1600 | else | |||
1601 | // if format is not available -> fallback to request without parameters | |||
1602 | pItem = nullptr; | |||
1603 | } | |||
1604 | ||||
1605 | if ( !pItem ) | |||
1606 | { | |||
1607 | if ( ScTransferObj::GetOwnClipboard(xTransferable) ) // own cell data | |||
1608 | { | |||
1609 | rReq.SetSlot( FID_INS_CELL_CONTENTS((((((((26000 + 200) + 20)) + 20)) + 20)) + 5) ); | |||
1610 | ExecuteSlot( rReq, GetInterface() ); | |||
1611 | rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success | |||
1612 | } | |||
1613 | else // draw objects or external data | |||
1614 | { | |||
1615 | bool bDraw = ( ScDrawTransferObj::GetOwnClipboard(xTransferable) != nullptr ); | |||
1616 | ||||
1617 | SvxClipboardFormatItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS(5000 + 312) ); | |||
1618 | GetPossibleClipboardFormats( aFormats ); | |||
1619 | ||||
1620 | sal_uInt16 nFormatCount = aFormats.Count(); | |||
1621 | if ( nFormatCount ) | |||
1622 | { | |||
1623 | SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); | |||
1624 | ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog(pTabViewShell->GetFrameWeld())); | |||
1625 | for (sal_uInt16 i=0; i<nFormatCount; i++) | |||
1626 | { | |||
1627 | SotClipboardFormatId nFormatId = aFormats.GetClipbrdFormatId( i ); | |||
1628 | OUString aName = aFormats.GetClipbrdFormatName( i ); | |||
1629 | // special case for paste dialog: '*' is replaced by object type | |||
1630 | if ( nFormatId == SotClipboardFormatId::EMBED_SOURCE ) | |||
1631 | aName = "*"; | |||
1632 | pDlg->Insert( nFormatId, aName ); | |||
1633 | } | |||
1634 | ||||
1635 | SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame(); | |||
1636 | auto xFrame = pViewFrame->GetFrame().GetFrameInterface(); | |||
1637 | const OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame)); | |||
1638 | auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:PasteTextImportDialog", aModuleName); | |||
1639 | OUString sLabel(vcl::CommandInfoProvider::GetTooltipLabelForCommand(aProperties)); | |||
1640 | pDlg->InsertUno(".uno:PasteTextImportDialog", sLabel); | |||
1641 | ||||
1642 | TransferableDataHelper aDataHelper( | |||
1643 | TransferableDataHelper::CreateFromSystemClipboard( pWin ) ); | |||
1644 | SotClipboardFormatId nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() ); | |||
1645 | if (nFormat != SotClipboardFormatId::NONE) | |||
1646 | { | |||
1647 | { | |||
1648 | weld::WaitObject aWait( GetViewData()->GetDialogParent() ); | |||
1649 | if ( bDraw && nFormat == SotClipboardFormatId::EMBED_SOURCE ) | |||
1650 | pTabViewShell->PasteDraw(); | |||
1651 | else | |||
1652 | pTabViewShell->PasteFromSystem(nFormat); | |||
1653 | } | |||
1654 | rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success | |||
1655 | rReq.AppendItem( SfxUInt32Item( nSlot, static_cast<sal_uInt32>(nFormat) ) ); | |||
1656 | rReq.Done(); | |||
1657 | } | |||
1658 | else | |||
1659 | { | |||
1660 | rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail | |||
1661 | rReq.Ignore(); | |||
1662 | } | |||
1663 | } | |||
1664 | else | |||
1665 | rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail | |||
1666 | } | |||
1667 | } | |||
1668 | } | |||
1669 | pTabViewShell->CellContentChanged(); // => PasteFromSystem() ??? | |||
1670 | break; | |||
1671 | ||||
1672 | case SID_PASTE_UNFORMATTED(5000 + 314): | |||
1673 | // differentiate between own cell data and draw objects/external data | |||
1674 | // this makes FID_INS_CELL_CONTENTS superfluous | |||
1675 | { | |||
1676 | weld::WaitObject aWait( GetViewData()->GetDialogParent() ); | |||
1677 | ||||
1678 | // we should differentiate between SotClipboardFormatId::STRING and SotClipboardFormatId::STRING_TSVC, | |||
1679 | // and paste the SotClipboardFormatId::STRING_TSVC if it is available. | |||
1680 | // Which makes a difference if the clipboard contains cells with embedded line breaks. | |||
1681 | ||||
1682 | SotClipboardFormatId nFormat = HasClipboardFormat( SotClipboardFormatId::STRING_TSVC) ? | |||
1683 | SotClipboardFormatId::STRING_TSVC : SotClipboardFormatId::STRING; | |||
1684 | ||||
1685 | const bool bRet = pTabViewShell->PasteFromSystem(nFormat, true); // TRUE: no error messages | |||
1686 | if ( bRet ) | |||
1687 | { | |||
1688 | rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = success | |||
1689 | rReq.Done(); | |||
1690 | } | |||
1691 | else | |||
1692 | { | |||
1693 | rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = fail | |||
1694 | } | |||
1695 | ||||
1696 | pTabViewShell->CellContentChanged(); // => PasteFromSystem() ??? | |||
1697 | } | |||
1698 | break; | |||
1699 | ||||
1700 | // other | |||
1701 | ||||
1702 | case FID_INS_ROWBRK((((((((26000 + 200) + 20)) + 20)) + 20)) + 1): | |||
1703 | pTabViewShell->InsertPageBreak( false ); | |||
1704 | rReq.Done(); | |||
1705 | break; | |||
1706 | ||||
1707 | case FID_INS_COLBRK((((((((26000 + 200) + 20)) + 20)) + 20)) + 2): | |||
1708 | pTabViewShell->InsertPageBreak( true ); | |||
1709 | rReq.Done(); | |||
1710 | break; | |||
1711 | ||||
1712 | case FID_DEL_ROWBRK((((((((26000 + 200) + 20)) + 20)) + 20)) + 3): | |||
1713 | pTabViewShell->DeletePageBreak( false ); | |||
1714 | rReq.Done(); | |||
1715 | break; | |||
1716 | ||||
1717 | case FID_DEL_COLBRK((((((((26000 + 200) + 20)) + 20)) + 20)) + 4): | |||
1718 | pTabViewShell->DeletePageBreak( true ); | |||
1719 | rReq.Done(); | |||
1720 | break; | |||
1721 | ||||
1722 | case SID_DETECTIVE_ADD_PRED((((((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 29)) + 20))+20))+1))+50))+20))): | |||
1723 | pTabViewShell->DetectiveAddPred(); | |||
1724 | rReq.Done(); | |||
1725 | break; | |||
1726 | ||||
1727 | case SID_DETECTIVE_DEL_PRED((((((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 29)) + 20))+20))+1))+50))+20))+1): | |||
1728 | pTabViewShell->DetectiveDelPred(); | |||
1729 | rReq.Done(); | |||
1730 | break; | |||
1731 | ||||
1732 | case SID_DETECTIVE_ADD_SUCC((((((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 29)) + 20))+20))+1))+50))+20))+2): | |||
1733 | pTabViewShell->DetectiveAddSucc(); | |||
1734 | rReq.Done(); | |||
1735 | break; | |||
1736 | ||||
1737 | case SID_DETECTIVE_DEL_SUCC((((((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 29)) + 20))+20))+1))+50))+20))+3): | |||
1738 | pTabViewShell->DetectiveDelSucc(); | |||
1739 | rReq.Done(); | |||
1740 | break; | |||
1741 | ||||
1742 | case SID_DETECTIVE_ADD_ERR((((((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 29)) + 20))+20))+1))+50))+20))+4): | |||
1743 | pTabViewShell->DetectiveAddError(); | |||
1744 | rReq.Done(); | |||
1745 | break; | |||
1746 | ||||
1747 | case SID_DETECTIVE_INVALID((((((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 29)) + 20))+20))+1))+50))+20))+13): | |||
1748 | pTabViewShell->DetectiveMarkInvalid(); | |||
1749 | rReq.Done(); | |||
1750 | break; | |||
1751 | ||||
1752 | case SID_DETECTIVE_REFRESH((((((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 29)) + 20))+20))+1))+50))+20))+14): | |||
1753 | pTabViewShell->DetectiveRefresh(); | |||
1754 | rReq.Done(); | |||
1755 | break; | |||
1756 | ||||
1757 | case SID_DETECTIVE_MARK_PRED((((((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 29)) + 20))+20))+1))+50))+20))+16): | |||
1758 | pTabViewShell->DetectiveMarkPred(); | |||
1759 | break; | |||
1760 | case SID_DETECTIVE_MARK_SUCC((((((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 29)) + 20))+20))+1))+50))+20))+17): | |||
1761 | pTabViewShell->DetectiveMarkSucc(); | |||
1762 | break; | |||
1763 | case SID_INSERT_CURRENT_DATE((20000 +5000)+16): | |||
1764 | pTabViewShell->InsertCurrentTime( | |||
1765 | SvNumFormatType::DATE, ScResId(STR_UNDO_INSERT_CURRENT_DATEreinterpret_cast<char const *>("STR_UNDO_INSERT_CURRENT_DATE" "\004" u8"Insert Current Date"))); | |||
1766 | break; | |||
1767 | case SID_INSERT_CURRENT_TIME((20000 +5000)+17): | |||
1768 | pTabViewShell->InsertCurrentTime( | |||
1769 | SvNumFormatType::TIME, ScResId(STR_UNDO_INSERT_CURRENT_TIMEreinterpret_cast<char const *>("STR_UNDO_INSERT_CURRENT_TIME" "\004" u8"Insert Current Time"))); | |||
1770 | break; | |||
1771 | ||||
1772 | case SID_SPELL_DIALOG( 10000 + 243 ): | |||
1773 | { | |||
1774 | SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame(); | |||
1775 | if( rReq.GetArgs() ) | |||
1776 | pViewFrame->SetChildWindow( SID_SPELL_DIALOG( 10000 + 243 ), | |||
1777 | static_cast< const SfxBoolItem& >( rReq.GetArgs()-> | |||
1778 | Get( SID_SPELL_DIALOG( 10000 + 243 ) ) ).GetValue() ); | |||
1779 | else | |||
1780 | pViewFrame->ToggleChildWindow( SID_SPELL_DIALOG( 10000 + 243 ) ); | |||
1781 | ||||
1782 | pViewFrame->GetBindings().Invalidate( SID_SPELL_DIALOG( 10000 + 243 ) ); | |||
1783 | rReq.Ignore(); | |||
1784 | } | |||
1785 | break; | |||
1786 | ||||
1787 | case SID_HANGUL_HANJA_CONVERSION( 10000 + 959 ): | |||
1788 | pTabViewShell->DoHangulHanjaConversion(); | |||
1789 | break; | |||
1790 | ||||
1791 | case SID_CHINESE_CONVERSION( 10000 + 1016 ): | |||
1792 | { | |||
1793 | //open ChineseTranslationDialog | |||
1794 | Reference< XComponentContext > xContext( | |||
1795 | ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one | |||
1796 | if(xContext.is()) | |||
1797 | { | |||
1798 | Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); | |||
1799 | if(xMCF.is()) | |||
1800 | { | |||
1801 | Reference< ui::dialogs::XExecutableDialog > xDialog( | |||
1802 | xMCF->createInstanceWithContext( | |||
1803 | "com.sun.star.linguistic2.ChineseTranslationDialog" | |||
1804 | , xContext), | |||
1805 | UNO_QUERY); | |||
1806 | Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY ); | |||
1807 | if( xInit.is() ) | |||
1808 | { | |||
1809 | // initialize dialog | |||
1810 | uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence( | |||
1811 | { | |||
1812 | {"ParentWindow", uno::Any(Reference< awt::XWindow >())} | |||
1813 | })); | |||
1814 | xInit->initialize( aSeq ); | |||
1815 | ||||
1816 | //execute dialog | |||
1817 | sal_Int16 nDialogRet = xDialog->execute(); | |||
1818 | if( RET_OK == nDialogRet ) | |||
1819 | { | |||
1820 | //get some parameters from the dialog | |||
1821 | bool bToSimplified = true; | |||
1822 | bool bUseVariants = true; | |||
1823 | bool bCommonTerms = true; | |||
1824 | Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY ); | |||
1825 | if( xProp.is() ) | |||
1826 | { | |||
1827 | try | |||
1828 | { | |||
1829 | xProp->getPropertyValue("IsDirectionToSimplified") >>= bToSimplified; | |||
1830 | xProp->getPropertyValue("IsUseCharacterVariants") >>= bUseVariants; | |||
1831 | xProp->getPropertyValue("IsTranslateCommonTerms") >>= bCommonTerms; | |||
1832 | } | |||
1833 | catch( Exception& ) | |||
1834 | { | |||
1835 | } | |||
1836 | } | |||
1837 | ||||
1838 | //execute translation | |||
1839 | LanguageType eSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONALLanguageType(0x0404) : LANGUAGE_CHINESE_SIMPLIFIEDLanguageType(0x0804); | |||
1840 | LanguageType eTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIEDLanguageType(0x0804) : LANGUAGE_CHINESE_TRADITIONALLanguageType(0x0404); | |||
1841 | sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0; | |||
1842 | if( !bCommonTerms ) | |||
1843 | nOptions |= i18n::TextConversionOption::CHARACTER_BY_CHARACTER; | |||
1844 | ||||
1845 | vcl::Font aTargetFont = OutputDevice::GetDefaultFont( | |||
1846 | DefaultFontType::CJK_SPREADSHEET, | |||
1847 | eTargetLang, GetDefaultFontFlags::OnlyOne ); | |||
1848 | ScConversionParam aConvParam( SC_CONVERSION_CHINESE_TRANSL, | |||
1849 | eSourceLang, eTargetLang, aTargetFont, nOptions, false ); | |||
1850 | pTabViewShell->DoSheetConversion( aConvParam ); | |||
1851 | } | |||
1852 | } | |||
1853 | Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY ); | |||
1854 | if( xComponent.is() ) | |||
1855 | xComponent->dispose(); | |||
1856 | } | |||
1857 | } | |||
1858 | } | |||
1859 | break; | |||
1860 | ||||
1861 | case SID_CONVERT_FORMULA_TO_VALUE((26000 + 200) + 5): | |||
1862 | { | |||
1863 | pTabViewShell->ConvertFormulaToValue(); | |||
1864 | } | |||
1865 | break; | |||
1866 | case SID_THESAURUS( 10000 + 245 ): | |||
1867 | pTabViewShell->DoThesaurus(); | |||
1868 | break; | |||
1869 | ||||
1870 | case SID_TOGGLE_REL((((26000 + 521) + 50))+38): | |||
1871 | pTabViewShell->DoRefConversion(); | |||
1872 | break; | |||
1873 | ||||
1874 | case SID_DEC_INDENT( 10000 + 461 ): | |||
1875 | pTabViewShell->ChangeIndent( false ); | |||
1876 | break; | |||
1877 | case SID_INC_INDENT( 10000 + 462 ): | |||
1878 | pTabViewShell->ChangeIndent( true ); | |||
1879 | break; | |||
1880 | ||||
1881 | case FID_USE_NAME((((((((26000 + 200) + 20)) + 20)) + 20)) + 13): | |||
1882 | { | |||
1883 | CreateNameFlags nFlags = pTabViewShell->GetCreateNameFlags(); | |||
1884 | ||||
1885 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
1886 | ||||
1887 | ScopedVclPtr<AbstractScNameCreateDlg> pDlg(pFact->CreateScNameCreateDlg(pTabViewShell->GetFrameWeld(), nFlags)); | |||
1888 | ||||
1889 | if( pDlg->Execute() ) | |||
1890 | { | |||
1891 | pTabViewShell->CreateNames(pDlg->GetFlags()); | |||
1892 | rReq.Done(); | |||
1893 | } | |||
1894 | } | |||
1895 | break; | |||
1896 | ||||
1897 | case SID_CONSOLIDATE((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 20): | |||
1898 | { | |||
1899 | const SfxPoolItem* pItem; | |||
1900 | if ( pReqArgs && SfxItemState::SET == | |||
1901 | pReqArgs->GetItemState( SCITEM_CONSOLIDATEDATA1105, true, &pItem ) ) | |||
1902 | { | |||
1903 | const ScConsolidateParam& rParam = | |||
1904 | static_cast<const ScConsolidateItem*>(pItem)->GetData(); | |||
1905 | ||||
1906 | pTabViewShell->Consolidate( rParam ); | |||
1907 | GetViewData()->GetDocument().SetConsolidateDlgData( std::unique_ptr<ScConsolidateParam>(new ScConsolidateParam(rParam)) ); | |||
1908 | ||||
1909 | rReq.Done(); | |||
1910 | } | |||
1911 | #if HAVE_FEATURE_SCRIPTING1 | |||
1912 | else if (rReq.IsAPI()) | |||
1913 | SbxBase::SetError(ERRCODE_BASIC_BAD_PARAMETERErrCode( ErrCodeArea::Sbx, ErrCodeClass::Runtime, 7)); | |||
1914 | #endif | |||
1915 | } | |||
1916 | break; | |||
1917 | ||||
1918 | case SID_INS_FUNCTION((((((((26000 + 200) + 20)) + 20)) + 20)) + 10): | |||
1919 | { | |||
1920 | const SfxBoolItem* pOkItem = static_cast<const SfxBoolItem*>(&pReqArgs->Get( SID_DLG_RETOK((26000 + 100) + 12) )); | |||
1921 | ||||
1922 | if ( pOkItem->GetValue() ) // OK | |||
1923 | { | |||
1924 | OUString aFormula; | |||
1925 | const SfxStringItem* pSItem = static_cast<const SfxStringItem*>(&pReqArgs->Get( SCITEM_STRING1100 )); | |||
1926 | const SfxBoolItem* pMatrixItem = static_cast<const SfxBoolItem*>(&pReqArgs->Get( SID_DLG_MATRIX((26000 + 100) + 18) )); | |||
1927 | ||||
1928 | aFormula += pSItem->GetValue(); | |||
1929 | pScMod->ActivateInputWindow( &aFormula, pMatrixItem->GetValue() ); | |||
1930 | } | |||
1931 | else // CANCEL | |||
1932 | { | |||
1933 | pScMod->ActivateInputWindow(); | |||
1934 | } | |||
1935 | rReq.Ignore(); // only SID_ENTER_STRING is recorded | |||
1936 | } | |||
1937 | break; | |||
1938 | ||||
1939 | case FID_DEFINE_NAME((((((((26000 + 200) + 20)) + 20)) + 20)) + 11): | |||
1940 | case FID_DEFINE_CURRENT_NAME((((((((26000 + 200) + 20)) + 20)) + 20)) + 24): | |||
1941 | if ( pReqArgs ) | |||
1942 | { | |||
1943 | const SfxPoolItem* pItem; | |||
1944 | OUString aName, aSymbol, aAttrib; | |||
1945 | ||||
1946 | if( pReqArgs->HasItem( FID_DEFINE_NAME((((((((26000 + 200) + 20)) + 20)) + 20)) + 11), &pItem ) ) | |||
1947 | aName = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
1948 | ||||
1949 | if( pReqArgs->HasItem( FN_PARAM_1((20000 + 1100)+60), &pItem ) ) | |||
1950 | aSymbol = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
1951 | ||||
1952 | if( pReqArgs->HasItem( FN_PARAM_2((20000 + 1100)+61), &pItem ) ) | |||
1953 | aAttrib = static_cast<const SfxStringItem*>(pItem)->GetValue(); | |||
1954 | ||||
1955 | if ( !aName.isEmpty() && !aSymbol.isEmpty() ) | |||
1956 | { | |||
1957 | if (pTabViewShell->InsertName( aName, aSymbol, aAttrib )) | |||
1958 | rReq.Done(); | |||
1959 | #if HAVE_FEATURE_SCRIPTING1 | |||
1960 | else | |||
1961 | SbxBase::SetError( ERRCODE_BASIC_BAD_PARAMETERErrCode( ErrCodeArea::Sbx, ErrCodeClass::Runtime, 7) ); // Basic-error | |||
1962 | #endif | |||
1963 | } | |||
1964 | } | |||
1965 | else | |||
1966 | { | |||
1967 | sal_uInt16 nId = ScNameDlgWrapper::GetChildWindowId(); | |||
1968 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
1969 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
1970 | ||||
1971 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
1972 | } | |||
1973 | break; | |||
1974 | case FID_ADD_NAME((((((((26000 + 200) + 20)) + 20)) + 20)) + 16): | |||
1975 | { | |||
1976 | sal_uInt16 nId = ScNameDefDlgWrapper::GetChildWindowId(); | |||
1977 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
1978 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
1979 | ||||
1980 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
1981 | } | |||
1982 | break; | |||
1983 | ||||
1984 | case SID_OPENDLG_CONDFRMT((26000 + 100) + 59): | |||
1985 | case SID_OPENDLG_CURRENTCONDFRMT((26000 + 100) + 58): | |||
1986 | case SID_OPENDLG_COLORSCALE((26000 + 100) + 66): | |||
1987 | case SID_OPENDLG_DATABAR((26000 + 100) + 67): | |||
1988 | case SID_OPENDLG_ICONSET((26000 + 100) + 68): | |||
1989 | case SID_OPENDLG_CONDDATE((26000 + 100) + 69): | |||
1990 | { | |||
1991 | sal_uInt32 nIndex = sal_uInt32(-1); | |||
1992 | bool bManaged = false; | |||
1993 | ||||
1994 | // Get the pool item stored by Conditional Format Manager Dialog. | |||
1995 | auto itemsRange = pTabViewShell->GetPool().GetItemSurrogates(SCITEM_CONDFORMATDLGDATA1109); | |||
1996 | if (itemsRange.begin() != itemsRange.end()) | |||
1997 | { | |||
1998 | const ScCondFormatDlgItem* pDlgItem = static_cast<const ScCondFormatDlgItem*>(*itemsRange.begin()); | |||
1999 | nIndex = pDlgItem->GetIndex(); | |||
2000 | bManaged = true; | |||
2001 | } | |||
2002 | ||||
2003 | // Check if the Conditional Manager Dialog is editing or adding | |||
2004 | // conditional format item. | |||
2005 | if ( bManaged ) | |||
2006 | { | |||
2007 | sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId(); | |||
2008 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
2009 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
2010 | ||||
2011 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
2012 | break; | |||
2013 | } | |||
2014 | ||||
2015 | ScRangeList aRangeList; | |||
2016 | ScViewData* pData = GetViewData(); | |||
2017 | pData->GetMarkData().FillRangeListWithMarks(&aRangeList, false); | |||
2018 | ||||
2019 | ScDocument& rDoc = GetViewData()->GetDocument(); | |||
2020 | if(rDoc.IsTabProtected(pData->GetTabNo())) | |||
2021 | { | |||
2022 | pTabViewShell->ErrorMessage( STR_ERR_CONDFORMAT_PROTECTEDreinterpret_cast<char const *>("STR_ERR_CONDFORMAT_PROTECTED" "\004" u8"Conditional Formats can not be created, deleted or changed in protected sheets." ) ); | |||
2023 | break; | |||
2024 | } | |||
2025 | ||||
2026 | ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo()); | |||
2027 | if(aRangeList.empty()) | |||
2028 | { | |||
2029 | aRangeList.push_back(ScRange(aPos)); | |||
2030 | } | |||
2031 | ||||
2032 | // try to find an existing conditional format | |||
2033 | const ScConditionalFormat* pCondFormat = nullptr; | |||
2034 | const ScPatternAttr* pPattern = rDoc.GetPattern(aPos.Col(), aPos.Row(), aPos.Tab()); | |||
2035 | ScConditionalFormatList* pList = rDoc.GetCondFormList(aPos.Tab()); | |||
2036 | const ScCondFormatIndexes& rCondFormats = pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData(); | |||
2037 | bool bContainsCondFormat = !rCondFormats.empty(); | |||
2038 | bool bCondFormatDlg = false; | |||
2039 | bool bContainsExistingCondFormat = false; | |||
2040 | if(bContainsCondFormat) | |||
2041 | { | |||
2042 | for (const auto& rCondFormat : rCondFormats) | |||
2043 | { | |||
2044 | // check if at least one existing conditional format has the same range | |||
2045 | pCondFormat = pList->GetFormat(rCondFormat); | |||
2046 | if(!pCondFormat) | |||
2047 | continue; | |||
2048 | ||||
2049 | bContainsExistingCondFormat = true; | |||
2050 | const ScRangeList& rCondFormatRange = pCondFormat->GetRange(); | |||
2051 | if(rCondFormatRange == aRangeList) | |||
2052 | { | |||
2053 | // found a matching range, edit this conditional format | |||
2054 | bCondFormatDlg = true; | |||
2055 | nIndex = pCondFormat->GetKey(); | |||
2056 | break; | |||
2057 | } | |||
2058 | } | |||
2059 | } | |||
2060 | ||||
2061 | // do we have a parameter with the conditional formatting type? | |||
2062 | const SfxInt16Item* pParam = rReq.GetArg<SfxInt16Item>(FN_PARAM_1((20000 + 1100)+60)); | |||
2063 | if (pParam && nSlot == SID_OPENDLG_ICONSET((26000 + 100) + 68)) | |||
2064 | { | |||
2065 | auto pFormat = std::make_unique<ScConditionalFormat>(0, &rDoc); | |||
2066 | pFormat->SetRange(aRangeList); | |||
2067 | ||||
2068 | ScIconSetType eIconSetType = limit_cast<ScIconSetType>(pParam->GetValue(), IconSet_3Arrows, IconSet_5Boxes); | |||
2069 | const int nSteps = ScIconSetFormat::getIconSetElements(eIconSetType); | |||
2070 | ||||
2071 | ScIconSetFormat* pEntry = new ScIconSetFormat(&rDoc); | |||
2072 | ScIconSetFormatData* pIconSetFormatData = new ScIconSetFormatData(eIconSetType); | |||
2073 | ||||
2074 | pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(0, COL_RED, COLORSCALE_PERCENT)); | |||
2075 | pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(100. / nSteps), COL_BROWN, COLORSCALE_PERCENT)); | |||
2076 | pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(200. / nSteps), COL_YELLOW, COLORSCALE_PERCENT)); | |||
2077 | if (nSteps > 3) | |||
2078 | pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(300. / nSteps), COL_WHITE, COLORSCALE_PERCENT)); | |||
2079 | if (nSteps > 4) | |||
2080 | pIconSetFormatData->m_Entries.emplace_back(new ScColorScaleEntry(round(400. / nSteps), COL_GREEN, COLORSCALE_PERCENT)); | |||
2081 | ||||
2082 | pEntry->SetIconSetData(pIconSetFormatData); | |||
2083 | pFormat->AddEntry(pEntry); | |||
2084 | ||||
2085 | // use the new conditional formatting | |||
2086 | GetViewData()->GetDocShell()->GetDocFunc().ReplaceConditionalFormat(nIndex, std::move(pFormat), aPos.Tab(), aRangeList); | |||
2087 | ||||
2088 | break; | |||
2089 | } | |||
2090 | ||||
2091 | // if not found a conditional format ask whether we should edit one of the existing | |||
2092 | // or should create a new overlapping conditional format | |||
2093 | if(bContainsCondFormat && !bCondFormatDlg && bContainsExistingCondFormat) | |||
2094 | { | |||
2095 | std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(), | |||
2096 | VclMessageType::Question, VclButtonsType::YesNo, | |||
2097 | ScResId(STR_EDIT_EXISTING_COND_FORMATSreinterpret_cast<char const *>("STR_EDIT_EXISTING_COND_FORMATS" "\004" u8"The selected cell already contains conditional formatting. You can either edit the existing conditional format or you define a new overlapping conditional format.\n\n Do you want to edit the existing conditional format?" )))); | |||
2098 | xQueryBox->set_default_response(RET_YES); | |||
2099 | bool bEditExisting = xQueryBox->run() == RET_YES; | |||
2100 | if (bEditExisting) | |||
2101 | { | |||
2102 | // differentiate between ranges where one conditional format is defined | |||
2103 | // and several formats are defined | |||
2104 | // if we have only one => open the cond format dlg to edit it | |||
2105 | // otherwise open the manage cond format dlg | |||
2106 | if (rCondFormats.size() == 1) | |||
2107 | { | |||
2108 | pCondFormat = pList->GetFormat(rCondFormats[0]); | |||
2109 | assert(pCondFormat)(static_cast <bool> (pCondFormat) ? void (0) : __assert_fail ("pCondFormat", "/home/maarten/src/libreoffice/core/sc/source/ui/view/cellsh1.cxx" , 2109, __extension__ __PRETTY_FUNCTION__)); | |||
2110 | bCondFormatDlg = true; | |||
2111 | } | |||
2112 | else | |||
2113 | { | |||
2114 | // Queue message to open Conditional Format Manager Dialog. | |||
2115 | GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT_MANAGER((26000 + 100) + 62), SfxCallMode::ASYNCHRON ); | |||
2116 | break; | |||
2117 | } | |||
2118 | } | |||
2119 | else | |||
2120 | { | |||
2121 | // define an overlapping conditional format | |||
2122 | // does not need to be handled here | |||
2123 | } | |||
2124 | } | |||
2125 | ||||
2126 | condformat::dialog::ScCondFormatDialogType eType = condformat::dialog::NONE; | |||
2127 | switch(nSlot) | |||
2128 | { | |||
2129 | case SID_OPENDLG_CONDFRMT((26000 + 100) + 59): | |||
2130 | case SID_OPENDLG_CURRENTCONDFRMT((26000 + 100) + 58): | |||
2131 | eType = condformat::dialog::CONDITION; | |||
2132 | break; | |||
2133 | case SID_OPENDLG_COLORSCALE((26000 + 100) + 66): | |||
2134 | eType = condformat::dialog::COLORSCALE; | |||
2135 | break; | |||
2136 | case SID_OPENDLG_DATABAR((26000 + 100) + 67): | |||
2137 | eType = condformat::dialog::DATABAR; | |||
2138 | break; | |||
2139 | case SID_OPENDLG_ICONSET((26000 + 100) + 68): | |||
2140 | eType = condformat::dialog::ICONSET; | |||
2141 | break; | |||
2142 | case SID_OPENDLG_CONDDATE((26000 + 100) + 69): | |||
2143 | eType = condformat::dialog::DATE; | |||
2144 | break; | |||
2145 | default: | |||
2146 | assert(false)(static_cast <bool> (false) ? void (0) : __assert_fail ( "false", "/home/maarten/src/libreoffice/core/sc/source/ui/view/cellsh1.cxx" , 2146, __extension__ __PRETTY_FUNCTION__)); | |||
2147 | break; | |||
2148 | } | |||
2149 | ||||
2150 | ||||
2151 | if(bCondFormatDlg || !bContainsCondFormat) | |||
2152 | { | |||
2153 | // Put the xml string parameter to initialize the | |||
2154 | // Conditional Format Dialog. | |||
2155 | ScCondFormatDlgItem aDlgItem(nullptr, nIndex, false); | |||
2156 | aDlgItem.SetDialogType(eType); | |||
2157 | pTabViewShell->GetPool().Put(aDlgItem); | |||
2158 | ||||
2159 | sal_uInt16 nId = ScCondFormatDlgWrapper::GetChildWindowId(); | |||
2160 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
2161 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
2162 | ||||
2163 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
2164 | } | |||
2165 | } | |||
2166 | break; | |||
2167 | ||||
2168 | case SID_DEFINE_COLROWNAMERANGES((((26000 + 521) + 50))+58): | |||
2169 | { | |||
2170 | ||||
2171 | sal_uInt16 nId = ScColRowNameRangesDlgWrapper::GetChildWindowId(); | |||
2172 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
2173 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
2174 | ||||
2175 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
2176 | ||||
2177 | } | |||
2178 | break; | |||
2179 | ||||
2180 | case SID_UPDATECHART((26000) + 13): | |||
2181 | { | |||
2182 | bool bAll = false; | |||
2183 | ||||
2184 | if( pReqArgs ) | |||
2185 | { | |||
2186 | const SfxPoolItem* pItem; | |||
2187 | ||||
2188 | if( pReqArgs->HasItem( SID_UPDATECHART((26000) + 13), &pItem ) ) | |||
2189 | bAll = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | |||
2190 | } | |||
2191 | ||||
2192 | pTabViewShell->UpdateCharts( bAll ); | |||
2193 | ||||
2194 | if( ! rReq.IsAPI() ) | |||
2195 | { | |||
2196 | rReq.AppendItem( SfxBoolItem( SID_UPDATECHART((26000) + 13), bAll ) ); | |||
2197 | rReq.Done(); | |||
2198 | } | |||
2199 | } | |||
2200 | break; | |||
2201 | ||||
2202 | case SID_TABOP((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 18): | |||
2203 | if (pReqArgs) | |||
2204 | { | |||
2205 | const ScTabOpItem& rItem = | |||
2206 | static_cast<const ScTabOpItem&>( | |||
2207 | pReqArgs->Get( SID_TABOP((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 18) )); | |||
2208 | ||||
2209 | pTabViewShell->TabOp( rItem.GetData() ); | |||
2210 | ||||
2211 | rReq.Done( *pReqArgs ); | |||
2212 | } | |||
2213 | break; | |||
2214 | ||||
2215 | case SID_SOLVE((26000 + 100) + 6): | |||
2216 | if (pReqArgs) | |||
2217 | { | |||
2218 | const ScSolveItem& rItem = | |||
2219 | static_cast<const ScSolveItem&>( | |||
2220 | pReqArgs->Get( SCITEM_SOLVEDATA1107 )); | |||
2221 | ||||
2222 | pTabViewShell->Solve( rItem.GetData() ); | |||
2223 | ||||
2224 | rReq.Done( *pReqArgs ); | |||
2225 | } | |||
2226 | break; | |||
2227 | ||||
2228 | case FID_INSERT_NAME((((((((26000 + 200) + 20)) + 20)) + 20)) + 12): | |||
2229 | { | |||
2230 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
2231 | ||||
2232 | ScopedVclPtr<AbstractScNamePasteDlg> pDlg(pFact->CreateScNamePasteDlg(pTabViewShell->GetFrameWeld(), GetViewData()->GetDocShell())); | |||
2233 | switch( pDlg->Execute() ) | |||
2234 | { | |||
2235 | case BTN_PASTE_LIST101: | |||
2236 | pTabViewShell->InsertNameList(); | |||
2237 | break; | |||
2238 | case BTN_PASTE_NAME100: | |||
2239 | { | |||
2240 | ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell ); | |||
2241 | if (pHdl) | |||
2242 | { | |||
2243 | // "=" in KeyEvent, switches to input-mode | |||
2244 | (void)pScMod->InputKeyEvent( KeyEvent('=', vcl::KeyCode()) ); | |||
2245 | ||||
2246 | std::vector<OUString> aNames = pDlg->GetSelectedNames(); | |||
2247 | if (!aNames.empty()) | |||
2248 | { | |||
2249 | OUStringBuffer aBuffer; | |||
2250 | for (const auto& rName : aNames) | |||
2251 | { | |||
2252 | aBuffer.append(rName).append(' '); | |||
2253 | } | |||
2254 | pHdl->InsertFunction( aBuffer.makeStringAndClear(), false ); // without "()" | |||
2255 | } | |||
2256 | } | |||
2257 | } | |||
2258 | break; | |||
2259 | } | |||
2260 | } | |||
2261 | break; | |||
2262 | ||||
2263 | case SID_RANGE_NOTETEXT((((26000 + 521) + 50))+52): | |||
2264 | if (pReqArgs) | |||
2265 | { | |||
2266 | const SfxStringItem& rTextItem = static_cast<const SfxStringItem&>(pReqArgs->Get( SID_RANGE_NOTETEXT((((26000 + 521) + 50))+52) )); | |||
2267 | ||||
2268 | // always cursor position | |||
2269 | ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); | |||
2270 | pTabViewShell->SetNoteText( aPos, rTextItem.GetValue() ); | |||
2271 | rReq.Done(); | |||
2272 | } | |||
2273 | break; | |||
2274 | ||||
2275 | case SID_INSERT_POSTIT( 10000 + 1101 ): | |||
2276 | case SID_EDIT_POSTIT( 10000 + 1158 ): | |||
2277 | { | |||
2278 | const SfxPoolItem* pText; | |||
2279 | if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_TEXTTypedWhichId<SvxPostItTextItem>( 10000 + 46 ), &pText) ) | |||
2280 | { | |||
2281 | const SfxPoolItem* pCellId; | |||
2282 | OUString aCellId; | |||
2283 | // SID_ATTR_POSTIT_ID only argument for SID_EDIT_POSTIT | |||
2284 | if (pReqArgs->HasItem( SID_ATTR_POSTIT_IDTypedWhichId<SvxPostItIdItem>( 10000 + 47 ), &pCellId )) | |||
2285 | aCellId = static_cast<const SvxPostItIdItem*>(pCellId)->GetValue(); | |||
2286 | ||||
2287 | const SvxPostItTextItem* pTextItem = static_cast<const SvxPostItTextItem*>( pText ); | |||
2288 | const SvxPostItAuthorItem* pAuthorItem = pReqArgs->GetItem( SID_ATTR_POSTIT_AUTHORTypedWhichId<SvxPostItAuthorItem>( 10000 + 44 ) ); | |||
2289 | const SvxPostItDateItem* pDateItem = pReqArgs->GetItem( SID_ATTR_POSTIT_DATETypedWhichId<SvxPostItDateItem>( 10000 + 45 ) ); | |||
2290 | ||||
2291 | if (!aCellId.isEmpty()) | |||
2292 | { | |||
2293 | SetTabNoAndCursor( GetViewData(), aCellId ); | |||
2294 | } | |||
2295 | ||||
2296 | ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); | |||
2297 | pTabViewShell->ReplaceNote( aPos, pTextItem->GetValue(), | |||
2298 | pAuthorItem ? &pAuthorItem->GetValue() : nullptr, | |||
2299 | pDateItem ? &pDateItem->GetValue() : nullptr ); | |||
2300 | } | |||
2301 | else if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations()) | |||
2302 | { | |||
2303 | pTabViewShell->EditNote(); // note object to edit | |||
2304 | } | |||
2305 | rReq.Done(); | |||
2306 | } | |||
2307 | break; | |||
2308 | ||||
2309 | case FID_NOTE_VISIBLE((((26000 + 521) + 50))+59): | |||
2310 | { | |||
2311 | ScDocument& rDoc = GetViewData()->GetDocument(); | |||
2312 | ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ); | |||
2313 | if( ScPostIt* pNote = rDoc.GetNote(aPos) ) | |||
2314 | { | |||
2315 | bool bShow; | |||
2316 | const SfxPoolItem* pItem; | |||
2317 | if ( pReqArgs && (pReqArgs->GetItemState( FID_NOTE_VISIBLE((((26000 + 521) + 50))+59), true, &pItem ) == SfxItemState::SET) ) | |||
2318 | bShow = static_cast<const SfxBoolItem*>(pItem)->GetValue(); | |||
2319 | else | |||
2320 | bShow = !pNote->IsCaptionShown(); | |||
2321 | ||||
2322 | pTabViewShell->ShowNote( bShow ); | |||
2323 | ||||
2324 | if (!pReqArgs) | |||
2325 | rReq.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE((((26000 + 521) + 50))+59), bShow ) ); | |||
2326 | ||||
2327 | rReq.Done(); | |||
2328 | rBindings.Invalidate( FID_NOTE_VISIBLE((((26000 + 521) + 50))+59) ); | |||
2329 | } | |||
2330 | else | |||
2331 | rReq.Ignore(); | |||
2332 | } | |||
2333 | break; | |||
2334 | ||||
2335 | case FID_HIDE_NOTE((((26000 + 521) + 50))+101): | |||
2336 | case FID_SHOW_NOTE((((26000 + 521) + 50))+100): | |||
2337 | { | |||
2338 | bool bShowNote = nSlot == FID_SHOW_NOTE((((26000 + 521) + 50))+100); | |||
2339 | ScViewData* pData = GetViewData(); | |||
2340 | ScDocument& rDoc = pData->GetDocument(); | |||
2341 | ScMarkData& rMark = pData->GetMarkData(); | |||
2342 | ||||
2343 | if (!rMark.IsMarked() && !rMark.IsMultiMarked()) | |||
2344 | { | |||
2345 | // Check current cell | |||
2346 | ScAddress aPos( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() ); | |||
2347 | if( rDoc.GetNote(aPos) ) | |||
2348 | { | |||
2349 | pData->GetDocShell()->GetDocFunc().ShowNote( aPos, bShowNote ); | |||
2350 | } | |||
2351 | } | |||
2352 | else | |||
2353 | { | |||
2354 | // Check selection range | |||
2355 | bool bDone = false; | |||
2356 | ScRangeListRef aRangesRef; | |||
2357 | pData->GetMultiArea(aRangesRef); | |||
2358 | const ScRangeList aRanges = *aRangesRef; | |||
2359 | ||||
2360 | OUString aUndo = ScResId( bShowNote ? STR_UNDO_SHOWNOTEreinterpret_cast<char const *>("STR_UNDO_SHOWNOTE" "\004" u8"Show Comment") : STR_UNDO_HIDENOTEreinterpret_cast<char const *>("STR_UNDO_HIDENOTE" "\004" u8"Hide Comment") ); | |||
2361 | pData->GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, pData->GetViewShell()->GetViewShellId() ); | |||
2362 | ||||
2363 | for (auto const& rTab : rMark.GetSelectedTabs()) | |||
2364 | { | |||
2365 | // get notes | |||
2366 | std::vector<sc::NoteEntry> aNotes; | |||
2367 | rDoc.GetAllNoteEntries(rTab, aNotes); | |||
2368 | ||||
2369 | for (const sc::NoteEntry& rNote : aNotes) | |||
2370 | { | |||
2371 | // check if note is in our selection range | |||
2372 | const ScAddress& rAdr = rNote.maPos; | |||
2373 | const ScRange* rRange = aRanges.Find(rAdr); | |||
2374 | if (! rRange) | |||
2375 | continue; | |||
2376 | ||||
2377 | // check if cell is editable | |||
2378 | const SCTAB nRangeTab = rRange->aStart.Tab(); | |||
2379 | if (rDoc.IsBlockEditable( nRangeTab, rAdr.Col(), rAdr.Row(), rAdr.Col(), rAdr.Row() )) | |||
2380 | { | |||
2381 | pData->GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote ); | |||
2382 | bDone = true; | |||
2383 | } | |||
2384 | } | |||
2385 | } | |||
2386 | ||||
2387 | pData->GetDocShell()->GetUndoManager()->LeaveListAction(); | |||
2388 | ||||
2389 | if ( bDone ) | |||
2390 | { | |||
2391 | rReq.Done(); | |||
2392 | rBindings.Invalidate( nSlot ); | |||
2393 | } | |||
2394 | else | |||
2395 | rReq.Ignore(); | |||
2396 | } | |||
2397 | ||||
2398 | } | |||
2399 | break; | |||
2400 | ||||
2401 | case FID_SHOW_ALL_NOTES((((26000 + 521) + 50))+102): | |||
2402 | case FID_HIDE_ALL_NOTES((((26000 + 521) + 50))+103): | |||
2403 | { | |||
2404 | bool bShowNote = nSlot == FID_SHOW_ALL_NOTES((((26000 + 521) + 50))+102); | |||
2405 | ScViewData* pData = GetViewData(); | |||
2406 | ScMarkData& rMark = pData->GetMarkData(); | |||
2407 | ScDocument& rDoc = pData->GetDocument(); | |||
2408 | std::vector<sc::NoteEntry> aNotes; | |||
2409 | ||||
2410 | OUString aUndo = ScResId( bShowNote ? STR_UNDO_SHOWALLNOTESreinterpret_cast<char const *>("STR_UNDO_SHOWALLNOTES" "\004" u8"Show All Comments") : STR_UNDO_HIDEALLNOTESreinterpret_cast<char const *>("STR_UNDO_HIDEALLNOTES" "\004" u8"Hide All Comments") ); | |||
2411 | pData->GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, pData->GetViewShell()->GetViewShellId() ); | |||
2412 | ||||
2413 | for (auto const& rTab : rMark.GetSelectedTabs()) | |||
2414 | { | |||
2415 | rDoc.GetAllNoteEntries(rTab, aNotes); | |||
2416 | } | |||
2417 | ||||
2418 | for (const sc::NoteEntry& rNote : aNotes) | |||
2419 | { | |||
2420 | const ScAddress& rAdr = rNote.maPos; | |||
2421 | pData->GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote ); | |||
2422 | } | |||
2423 | ||||
2424 | pData->GetDocShell()->GetUndoManager()->LeaveListAction(); | |||
2425 | } | |||
2426 | break; | |||
2427 | ||||
2428 | case SID_TOGGLE_NOTES( 10000 + 1098 ): | |||
2429 | { | |||
2430 | ScViewData* pData = GetViewData(); | |||
2431 | ScMarkData& rMark = pData->GetMarkData(); | |||
2432 | ScDocument& rDoc = pData->GetDocument(); | |||
2433 | ScRangeList aRanges; | |||
2434 | std::vector<sc::NoteEntry> aNotes; | |||
2435 | ||||
2436 | for (auto const& rTab : rMark.GetSelectedTabs()) | |||
2437 | aRanges.push_back(ScRange(0,0,rTab,rDoc.MaxCol(),rDoc.MaxRow(),rTab)); | |||
2438 | ||||
2439 | CommentCaptionState eState = rDoc.GetAllNoteCaptionsState( aRanges ); | |||
2440 | rDoc.GetNotesInRange(aRanges, aNotes); | |||
2441 | bool bShowNote = (eState == ALLHIDDEN || eState == MIXED); | |||
2442 | ||||
2443 | OUString aUndo = ScResId( bShowNote ? STR_UNDO_SHOWALLNOTESreinterpret_cast<char const *>("STR_UNDO_SHOWALLNOTES" "\004" u8"Show All Comments") : STR_UNDO_HIDEALLNOTESreinterpret_cast<char const *>("STR_UNDO_HIDEALLNOTES" "\004" u8"Hide All Comments") ); | |||
2444 | pData->GetDocShell()->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, pData->GetViewShell()->GetViewShellId() ); | |||
2445 | ||||
2446 | for(const auto& rNote : aNotes) | |||
2447 | { | |||
2448 | const ScAddress& rAdr = rNote.maPos; | |||
2449 | pData->GetDocShell()->GetDocFunc().ShowNote( rAdr, bShowNote ); | |||
2450 | } | |||
2451 | ||||
2452 | pData->GetDocShell()->GetUndoManager()->LeaveListAction(); | |||
2453 | ||||
2454 | if (!pReqArgs) | |||
2455 | rReq.AppendItem( SfxBoolItem( SID_TOGGLE_NOTES( 10000 + 1098 ), bShowNote ) ); | |||
2456 | ||||
2457 | rReq.Done(); | |||
2458 | rBindings.Invalidate( SID_TOGGLE_NOTES( 10000 + 1098 ) ); | |||
2459 | } | |||
2460 | break; | |||
2461 | ||||
2462 | case SID_DELETE_NOTE((((((((((((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22)) + 20)) + 29)) + 20))+20))+1))+50))+20))+20))+2 ): | |||
2463 | { | |||
2464 | const SfxPoolItem* pId; | |||
2465 | // If Id is mentioned, select the appropriate cell first | |||
2466 | if ( pReqArgs && pReqArgs->HasItem( SID_ATTR_POSTIT_IDTypedWhichId<SvxPostItIdItem>( 10000 + 47 ), &pId) ) | |||
2467 | { | |||
2468 | const SvxPostItIdItem* pIdItem = static_cast<const SvxPostItIdItem*>(pId); | |||
2469 | const OUString& aCellId = pIdItem->GetValue(); | |||
2470 | if (!aCellId.isEmpty()) | |||
2471 | { | |||
2472 | SetTabNoAndCursor( GetViewData(), aCellId ); | |||
2473 | } | |||
2474 | } | |||
2475 | ||||
2476 | pTabViewShell->DeleteContents( InsertDeleteFlags::NOTE ); // delete all notes in selection | |||
2477 | rReq.Done(); | |||
2478 | } | |||
2479 | break; | |||
2480 | ||||
2481 | case FID_DELETE_ALL_NOTES((((26000 + 521) + 50))+104): | |||
2482 | { | |||
2483 | ScViewData* pData = GetViewData(); | |||
2484 | ScMarkData& rMark = pData->GetMarkData(); | |||
2485 | ScDocument& rDoc = pData->GetDocument(); | |||
2486 | ScMarkData aNewMark(rDoc.GetSheetLimits()); | |||
2487 | ScRangeList aRangeList; | |||
2488 | ||||
2489 | for (auto const& rTab : rMark.GetSelectedTabs()) | |||
2490 | { | |||
2491 | aRangeList.push_back(ScRange(0,0,rTab,rDoc.MaxCol(),rDoc.MaxRow(),rTab)); | |||
2492 | } | |||
2493 | ||||
2494 | aNewMark.MarkFromRangeList( aRangeList, true ); | |||
2495 | pData->GetDocShell()->GetDocFunc().DeleteContents(aNewMark, InsertDeleteFlags::NOTE, true, false ); | |||
2496 | } | |||
2497 | break; | |||
2498 | ||||
2499 | case SID_CHARMAP((10000 + 500) + 3): | |||
2500 | if( pReqArgs != nullptr ) | |||
2501 | { | |||
2502 | OUString aChars, aFontName; | |||
2503 | const SfxItemSet *pArgs = rReq.GetArgs(); | |||
2504 | const SfxPoolItem* pItem = nullptr; | |||
2505 | if ( pArgs ) | |||
2506 | pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP((10000 + 500) + 3)), false, &pItem); | |||
2507 | if ( pItem ) | |||
2508 | { | |||
2509 | const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>( pItem ); | |||
2510 | if ( pStringItem ) | |||
2511 | aChars = pStringItem->GetValue(); | |||
2512 | const SfxPoolItem* pFtItem = nullptr; | |||
2513 | pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR( 10000 + 1120 )), false, &pFtItem); | |||
2514 | const SfxStringItem* pFontItem = dynamic_cast<const SfxStringItem*>( pFtItem ); | |||
2515 | if ( pFontItem ) | |||
2516 | aFontName = pFontItem->GetValue(); | |||
2517 | } | |||
2518 | ||||
2519 | if ( !aChars.isEmpty() ) | |||
2520 | { | |||
2521 | vcl::Font aFont; | |||
2522 | pTabViewShell->GetSelectionPattern()->GetFont( aFont, SC_AUTOCOL_BLACK, nullptr, nullptr, nullptr, | |||
2523 | pTabViewShell->GetSelectionScriptType() ); | |||
2524 | if ( !aFontName.isEmpty() ) | |||
2525 | aFont = vcl::Font( aFontName, Size(1,1) ); | |||
2526 | pTabViewShell->InsertSpecialChar( aChars, aFont ); | |||
2527 | if( ! rReq.IsAPI() ) | |||
2528 | rReq.Done(); | |||
2529 | } | |||
2530 | } | |||
2531 | else | |||
2532 | { | |||
2533 | SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); | |||
2534 | ||||
2535 | // font color doesn't matter here | |||
2536 | vcl::Font aCurFont; | |||
2537 | pTabViewShell->GetSelectionPattern()->GetFont( aCurFont, SC_AUTOCOL_BLACK, nullptr, nullptr, nullptr, | |||
2538 | pTabViewShell->GetSelectionScriptType() ); | |||
2539 | ||||
2540 | SfxAllItemSet aSet( GetPool() ); | |||
2541 | aSet.Put( SfxBoolItem( FN_PARAM_1((20000 + 1100)+60), false ) ); | |||
2542 | aSet.Put( SvxFontItem( aCurFont.GetFamilyType(), aCurFont.GetFamilyName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT( 10000 + 7 )) ) ); | |||
2543 | SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame(); | |||
2544 | auto xFrame = pViewFrame->GetFrame().GetFrameInterface(); | |||
2545 | ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(pTabViewShell->GetFrameWeld(), aSet, xFrame)); | |||
2546 | pDlg->Execute(); | |||
2547 | } | |||
2548 | break; | |||
2549 | ||||
2550 | case SID_SELECT_SCENARIO((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22 )) + 20)) + 29)) + 20))+13): | |||
2551 | { | |||
2552 | // Testing | |||
2553 | ||||
2554 | if ( pReqArgs ) | |||
2555 | { | |||
2556 | const SfxStringItem& rItem | |||
2557 | = static_cast<const SfxStringItem&>(pReqArgs->Get(SID_SELECT_SCENARIO((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22 )) + 20)) + 29)) + 20))+13))); | |||
2558 | pTabViewShell->UseScenario(rItem.GetValue()); | |||
2559 | //! why should the return value be valid?!?! | |||
2560 | rReq.SetReturnValue(SfxStringItem(SID_SELECT_SCENARIO((((((((((((((((((26000 + 200) + 20)) + 20)) + 20)) + 25)) + 22 )) + 20)) + 29)) + 20))+13), rItem.GetValue())); | |||
2561 | rReq.Done(); | |||
2562 | } | |||
2563 | } | |||
2564 | break; | |||
2565 | ||||
2566 | case SID_HYPERLINK_SETLINKTypedWhichId<SvxHyperlinkItem>(10000 + 362): | |||
2567 | if( pReqArgs ) | |||
2568 | { | |||
2569 | const SfxPoolItem* pItem; | |||
2570 | if( pReqArgs->HasItem( SID_HYPERLINK_SETLINKTypedWhichId<SvxHyperlinkItem>(10000 + 362), &pItem ) ) | |||
2571 | { | |||
2572 | const SvxHyperlinkItem* pHyper = static_cast<const SvxHyperlinkItem*>(pItem); | |||
2573 | const OUString& rName = pHyper->GetName(); | |||
2574 | const OUString& rURL = pHyper->GetURL(); | |||
2575 | const OUString& rTarget = pHyper->GetTargetFrame(); | |||
2576 | sal_uInt16 nType = static_cast<sal_uInt16>(pHyper->GetInsertMode()); | |||
2577 | ||||
2578 | pTabViewShell->InsertURL( rName, rURL, rTarget, nType ); | |||
2579 | rReq.Done(); | |||
2580 | } | |||
2581 | else | |||
2582 | rReq.Ignore(); | |||
2583 | } | |||
2584 | break; | |||
2585 | ||||
2586 | case SID_OPENDLG_CONDFRMT_MANAGER((26000 + 100) + 62): | |||
2587 | case SID_OPENDLG_CURRENTCONDFRMT_MANAGER((26000 + 100) + 64): | |||
2588 | { | |||
2589 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
2590 | ||||
2591 | ScViewData* pData = GetViewData(); | |||
2592 | ScDocument& rDoc = pData->GetDocument(); | |||
2593 | ||||
2594 | if (rDoc.IsTabProtected(pData->GetTabNo())) | |||
2595 | { | |||
2596 | pTabViewShell->ErrorMessage( STR_ERR_CONDFORMAT_PROTECTEDreinterpret_cast<char const *>("STR_ERR_CONDFORMAT_PROTECTED" "\004" u8"Conditional Formats can not be created, deleted or changed in protected sheets." ) ); | |||
2597 | break; | |||
2598 | } | |||
2599 | ||||
2600 | ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo()); | |||
2601 | ||||
2602 | ScConditionalFormatList* pList = nullptr; | |||
2603 | ||||
2604 | const ScCondFormatDlgItem* pDlgItem = nullptr; | |||
2605 | auto itemsRange = pTabViewShell->GetPool().GetItemSurrogates(SCITEM_CONDFORMATDLGDATA1109); | |||
2606 | if (itemsRange.begin() != itemsRange.end()) | |||
2607 | { | |||
2608 | pDlgItem= static_cast<const ScCondFormatDlgItem*>(*itemsRange.begin()); | |||
2609 | pList = const_cast<ScCondFormatDlgItem*>(pDlgItem)->GetConditionalFormatList(); | |||
2610 | } | |||
2611 | ||||
2612 | if (!pList) | |||
2613 | pList = rDoc.GetCondFormList( aPos.Tab() ); | |||
2614 | ||||
2615 | VclPtr<AbstractScCondFormatManagerDlg> pDlg(pFact->CreateScCondFormatMgrDlg( | |||
2616 | pTabViewShell->GetFrameWeld(), rDoc, pList)); | |||
2617 | ||||
2618 | if (pDlgItem) | |||
2619 | pDlg->SetModified(); | |||
2620 | ||||
2621 | pDlg->StartExecuteAsync([this, pDlg, pData, pTabViewShell, pDlgItem, aPos](sal_Int32 nRet){ | |||
2622 | std::unique_ptr<ScConditionalFormatList> pCondFormatList = pDlg->GetConditionalFormatList(); | |||
2623 | if(nRet == RET_OK && pDlg->CondFormatsChanged()) | |||
2624 | { | |||
2625 | pData->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList.release(), aPos.Tab()); | |||
2626 | } | |||
2627 | else if(nRet == DLG_RET_ADD8) | |||
2628 | { | |||
2629 | // Put the xml string parameter to initialize the | |||
2630 | // Conditional Format Dialog. ( add new ) | |||
2631 | pTabViewShell->GetPool().Put(ScCondFormatDlgItem( | |||
2632 | std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), -1, true)); | |||
2633 | // Queue message to open Conditional Format Dialog | |||
2634 | GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT((26000 + 100) + 59), SfxCallMode::ASYNCHRON ); | |||
2635 | } | |||
2636 | else if (nRet == DLG_RET_EDIT16) | |||
2637 | { | |||
2638 | ScConditionalFormat* pFormat = pDlg->GetCondFormatSelected(); | |||
2639 | sal_Int32 nIndex = pFormat ? pFormat->GetKey() : -1; | |||
2640 | // Put the xml string parameter to initialize the | |||
2641 | // Conditional Format Dialog. ( edit selected conditional format ) | |||
2642 | pTabViewShell->GetPool().Put(ScCondFormatDlgItem( | |||
2643 | std::shared_ptr<ScConditionalFormatList>(pCondFormatList.release()), nIndex, true)); | |||
2644 | ||||
2645 | // Queue message to open Conditional Format Dialog | |||
2646 | GetViewData()->GetDispatcher().Execute( SID_OPENDLG_CONDFRMT((26000 + 100) + 59), SfxCallMode::ASYNCHRON ); | |||
2647 | } | |||
2648 | else | |||
2649 | pCondFormatList.reset(); | |||
2650 | ||||
2651 | if (pDlgItem) | |||
2652 | pTabViewShell->GetPool().Remove(*pDlgItem); | |||
2653 | ||||
2654 | pDlg->disposeOnce(); | |||
2655 | }); | |||
2656 | } | |||
2657 | break; | |||
2658 | ||||
2659 | case SID_EXTERNAL_SOURCE((26000) + 85): | |||
2660 | { | |||
2661 | const SfxStringItem* pFile = rReq.GetArg<SfxStringItem>(SID_FILE_NAME(5000 + 507)); | |||
2662 | const SfxStringItem* pSource = rReq.GetArg<SfxStringItem>(FN_PARAM_1((20000 + 1100)+60)); | |||
2663 | if ( pFile && pSource ) | |||
2664 | { | |||
2665 | OUString aFile; | |||
2666 | OUString aFilter; | |||
2667 | OUString aOptions; | |||
2668 | OUString aSource; | |||
2669 | sal_uLong nRefresh=0; | |||
2670 | ||||
2671 | aFile = pFile->GetValue(); | |||
2672 | aSource = pSource->GetValue(); | |||
2673 | const SfxStringItem* pFilter = rReq.GetArg<SfxStringItem>(SID_FILTER_NAME(5000 + 530)); | |||
2674 | if ( pFilter ) | |||
2675 | aFilter = pFilter->GetValue(); | |||
2676 | const SfxStringItem* pOptions = rReq.GetArg<SfxStringItem>(SID_FILE_FILTEROPTIONS(5000 + 527)); | |||
2677 | if ( pOptions ) | |||
2678 | aOptions = pOptions->GetValue(); | |||
2679 | const SfxUInt32Item* pRefresh = rReq.GetArg<SfxUInt32Item>(FN_PARAM_2((20000 + 1100)+61)); | |||
2680 | if ( pRefresh ) | |||
2681 | nRefresh = pRefresh->GetValue(); | |||
2682 | ||||
2683 | ExecuteExternalSource( aFile, aFilter, aOptions, aSource, nRefresh, rReq ); | |||
2684 | } | |||
2685 | else | |||
2686 | { | |||
2687 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
2688 | ||||
2689 | pImpl->m_pLinkedDlg.disposeAndClear(); | |||
2690 | pImpl->m_pLinkedDlg = | |||
2691 | pFact->CreateScLinkedAreaDlg(pTabViewShell->GetFrameWeld()); | |||
2692 | delete pImpl->m_pRequest; | |||
2693 | pImpl->m_pRequest = new SfxRequest( rReq ); | |||
2694 | OUString sFile, sFilter, sOptions, sSource; | |||
2695 | sal_uLong nRefresh = 0; | |||
2696 | if (pImpl->m_pLinkedDlg->Execute() == RET_OK) | |||
2697 | { | |||
2698 | sFile = pImpl->m_pLinkedDlg->GetURL(); | |||
2699 | sFilter = pImpl->m_pLinkedDlg->GetFilter(); | |||
2700 | sOptions = pImpl->m_pLinkedDlg->GetOptions(); | |||
2701 | sSource = pImpl->m_pLinkedDlg->GetSource(); | |||
2702 | nRefresh = pImpl->m_pLinkedDlg->GetRefresh(); | |||
2703 | if ( !sFile.isEmpty() ) | |||
2704 | pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_NAME(5000 + 507), sFile ) ); | |||
2705 | if ( !sFilter.isEmpty() ) | |||
2706 | pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILTER_NAME(5000 + 530), sFilter ) ); | |||
2707 | if ( !sOptions.isEmpty() ) | |||
2708 | pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS(5000 + 527), sOptions ) ); | |||
2709 | if ( !sSource.isEmpty() ) | |||
2710 | pImpl->m_pRequest->AppendItem( SfxStringItem( FN_PARAM_1((20000 + 1100)+60), sSource ) ); | |||
2711 | if ( nRefresh ) | |||
2712 | pImpl->m_pRequest->AppendItem( SfxUInt32Item( FN_PARAM_2((20000 + 1100)+61), nRefresh ) ); | |||
2713 | } | |||
2714 | ||||
2715 | ExecuteExternalSource( sFile, sFilter, sOptions, sSource, nRefresh, *(pImpl->m_pRequest) ); | |||
2716 | } | |||
2717 | } | |||
2718 | break; | |||
2719 | ||||
2720 | case SID_AUTO_SUM((26000 + 100) + 39): | |||
2721 | { | |||
2722 | bool bSubTotal = false; | |||
2723 | bool bRangeFinder = false; | |||
2724 | const OUString aFormula = pTabViewShell->DoAutoSum( bRangeFinder, bSubTotal , ocSum ); | |||
2725 | if ( !aFormula.isEmpty() ) | |||
2726 | { | |||
2727 | const sal_Int32 nPar = aFormula.indexOf( '(' ); | |||
2728 | const sal_Int32 nLen = aFormula.getLength(); | |||
2729 | ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell ); | |||
2730 | ||||
2731 | if ( pHdl && nPar != -1 ) | |||
2732 | { | |||
2733 | if ( !pScMod->IsEditMode() ) | |||
2734 | { | |||
2735 | pScMod->SetInputMode( SC_INPUT_TABLE ); | |||
2736 | } | |||
2737 | ||||
2738 | EditView *pEditView=pHdl->GetActiveView(); | |||
2739 | if ( pEditView ) | |||
2740 | { | |||
2741 | ESelection aTextSel = pEditView->GetSelection(); | |||
2742 | aTextSel.nStartPos = 0; | |||
2743 | aTextSel.nEndPos = EE_TEXTPOS_ALL((sal_Int32) 0x7FFFFFFF); | |||
2744 | pHdl->DataChanging(); | |||
2745 | pEditView->SetSelection(aTextSel); | |||
2746 | pEditView->InsertText(aFormula); | |||
2747 | pEditView->SetSelection( bRangeFinder ? ESelection( 0, nPar + ( bSubTotal ? 3 : 1 ), 0, nLen - 1 ) : ESelection( 0, nLen - 1, 0, nLen - 1 ) ); | |||
2748 | pHdl->DataChanged(); | |||
2749 | ||||
2750 | if ( bRangeFinder ) | |||
2751 | { | |||
2752 | pHdl->InitRangeFinder( aFormula ); | |||
2753 | } | |||
2754 | } | |||
2755 | } | |||
2756 | } | |||
2757 | } | |||
2758 | break; | |||
2759 | ||||
2760 | case SID_SELECT_UNPROTECTED_CELLS((((26000 + 521) + 50))+106): | |||
2761 | { | |||
2762 | ScViewData* pData = GetViewData(); | |||
2763 | SCTAB aTab = pData->GetTabNo(); | |||
2764 | ScMarkData& rMark = pData->GetMarkData(); | |||
2765 | ScDocument& rDoc = pData->GetDocument(); | |||
2766 | ScRangeList rRangeList; | |||
2767 | ||||
2768 | rDoc.GetUnprotectedCells(rRangeList, aTab); | |||
2769 | rMark.MarkFromRangeList(rRangeList, true); | |||
2770 | pTabViewShell->SetMarkData(rMark); | |||
2771 | } | |||
2772 | break; | |||
2773 | ||||
2774 | default: | |||
2775 | OSL_FAIL("incorrect slot in ExecuteEdit")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/cellsh1.cxx" ":" "2775" ": "), "%s", "incorrect slot in ExecuteEdit"); } } while (false); | |||
2776 | break; | |||
2777 | } | |||
2778 | } | |||
2779 | ||||
2780 | void ScCellShell::ExecuteTrans( SfxRequest& rReq ) | |||
2781 | { | |||
2782 | TransliterationFlags nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() ); | |||
2783 | if ( nType != TransliterationFlags::NONE ) | |||
2784 | { | |||
2785 | GetViewData()->GetView()->TransliterateText( nType ); | |||
2786 | rReq.Done(); | |||
2787 | } | |||
2788 | } | |||
2789 | ||||
2790 | void ScCellShell::ExecuteRotateTrans( const SfxRequest& rReq ) | |||
2791 | { | |||
2792 | if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE( 10000 + 1105 ) ) | |||
2793 | GetViewData()->GetView()->TransliterateText( m_aRotateCase.getNextMode() ); | |||
2794 | } | |||
2795 | ||||
2796 | void ScCellShell::ExecuteExternalSource( | |||
2797 | const OUString& _rFile, const OUString& _rFilter, const OUString& _rOptions, | |||
2798 | const OUString& _rSource, sal_uLong _nRefresh, SfxRequest& _rRequest ) | |||
2799 | { | |||
2800 | if ( !_rFile.isEmpty() && !_rSource.isEmpty() ) // filter may be empty | |||
2801 | { | |||
2802 | ScRange aLinkRange; | |||
2803 | bool bMove = false; | |||
2804 | ||||
2805 | ScViewData* pData = GetViewData(); | |||
2806 | ScMarkData& rMark = pData->GetMarkData(); | |||
2807 | rMark.MarkToSimple(); | |||
2808 | if ( rMark.IsMarked() ) | |||
2809 | { | |||
2810 | rMark.GetMarkArea( aLinkRange ); | |||
2811 | bMove = true; // insert/delete cells to fit range | |||
2812 | } | |||
2813 | else | |||
2814 | aLinkRange = ScRange( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() ); | |||
2815 | ||||
2816 | pData->GetDocFunc().InsertAreaLink( _rFile, _rFilter, _rOptions, _rSource, | |||
2817 | aLinkRange, _nRefresh, bMove, false ); | |||
2818 | _rRequest.Done(); | |||
2819 | } | |||
2820 | else | |||
2821 | _rRequest.Ignore(); | |||
2822 | } | |||
2823 | ||||
2824 | namespace { | |||
2825 | ||||
2826 | bool isDPSourceValid(const ScDPObject& rDPObj) | |||
2827 | { | |||
2828 | if (rDPObj.IsImportData()) | |||
2829 | { | |||
2830 | // If the data type is database, check if the database is still valid. | |||
2831 | const ScImportSourceDesc* pDesc = rDPObj.GetImportSourceDesc(); | |||
2832 | if (!pDesc) | |||
2833 | return false; | |||
2834 | ||||
2835 | const ScDPSaveData* pSaveData = rDPObj.GetSaveData(); | |||
2836 | const ScDPDimensionSaveData* pDimData = nullptr; | |||
2837 | if (pSaveData) | |||
2838 | pDimData = pSaveData->GetExistingDimensionData(); | |||
2839 | ||||
2840 | const ScDPCache* pCache = pDesc->CreateCache(pDimData); | |||
2841 | if (!pCache) | |||
2842 | // cache creation failed, probably due to invalid connection. | |||
2843 | return false; | |||
2844 | } | |||
2845 | return true; | |||
2846 | } | |||
2847 | ||||
2848 | } | |||
2849 | ||||
2850 | void ScCellShell::ExecuteDataPilotDialog() | |||
2851 | { | |||
2852 | ScModule* pScMod = SC_MOD()( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule ::Calc)) ); | |||
2853 | ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); | |||
2854 | ScViewData* pData = GetViewData(); | |||
2855 | ScDocument& rDoc = pData->GetDocument(); | |||
2856 | ||||
2857 | std::unique_ptr<ScDPObject> pNewDPObject; | |||
2858 | ||||
2859 | // ScPivot is no longer used... | |||
2860 | ScDPObject* pDPObj = rDoc.GetDPAtCursor( | |||
2861 | pData->GetCurX(), pData->GetCurY(), | |||
2862 | pData->GetTabNo() ); | |||
2863 | if ( pDPObj ) // on an existing table? | |||
2864 | { | |||
2865 | if (isDPSourceValid(*pDPObj)) | |||
2866 | pNewDPObject.reset(new ScDPObject(*pDPObj)); | |||
2867 | } | |||
2868 | else // create new table | |||
2869 | { | |||
2870 | const char* pSrcErrorId = nullptr; | |||
2871 | ||||
2872 | // select database range or data | |||
2873 | pTabViewShell->GetDBData( true, SC_DB_OLD ); | |||
2874 | ScMarkData& rMark = GetViewData()->GetMarkData(); | |||
2875 | if ( !rMark.IsMarked() && !rMark.IsMultiMarked() ) | |||
2876 | pTabViewShell->MarkDataArea( false ); | |||
2877 | ||||
2878 | // output to cursor position for non-sheet data | |||
2879 | ScAddress aDestPos( pData->GetCurX(), pData->GetCurY(), | |||
2880 | pData->GetTabNo() ); | |||
2881 | ||||
2882 | // first select type of source data | |||
2883 | ||||
2884 | bool bEnableExt = ScDPObject::HasRegisteredSources(); | |||
2885 | ||||
2886 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
2887 | ||||
2888 | ScopedVclPtr<AbstractScDataPilotSourceTypeDlg> pTypeDlg( | |||
2889 | pFact->CreateScDataPilotSourceTypeDlg( | |||
2890 | pTabViewShell->GetFrameWeld(), bEnableExt)); | |||
2891 | ||||
2892 | // Populate named ranges (if any). | |||
2893 | ScRangeName* pRangeName = rDoc.GetRangeName(); | |||
2894 | if (pRangeName) | |||
2895 | { | |||
2896 | ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end(); | |||
2897 | for (; itr != itrEnd; ++itr) | |||
2898 | pTypeDlg->AppendNamedRange(itr->second->GetName()); | |||
2899 | } | |||
2900 | ||||
2901 | if ( pTypeDlg->Execute() == RET_OK ) | |||
2902 | { | |||
2903 | if ( pTypeDlg->IsExternal() ) | |||
2904 | { | |||
2905 | std::vector<OUString> aSources = ScDPObject::GetRegisteredSources(); | |||
2906 | ScopedVclPtr<AbstractScDataPilotServiceDlg> pServDlg( | |||
2907 | pFact->CreateScDataPilotServiceDlg( | |||
2908 | pTabViewShell->GetFrameWeld(), aSources)); | |||
2909 | ||||
2910 | if ( pServDlg->Execute() == RET_OK ) | |||
2911 | { | |||
2912 | ScDPServiceDesc aServDesc( | |||
2913 | pServDlg->GetServiceName(), | |||
2914 | pServDlg->GetParSource(), | |||
2915 | pServDlg->GetParName(), | |||
2916 | pServDlg->GetParUser(), | |||
2917 | pServDlg->GetParPass() ); | |||
2918 | pNewDPObject.reset(new ScDPObject(&rDoc)); | |||
2919 | pNewDPObject->SetServiceData( aServDesc ); | |||
2920 | } | |||
2921 | } | |||
2922 | else if ( pTypeDlg->IsDatabase() ) | |||
2923 | { | |||
2924 | assert(pFact && "ScAbstractFactory create fail!")(static_cast <bool> (pFact && "ScAbstractFactory create fail!" ) ? void (0) : __assert_fail ("pFact && \"ScAbstractFactory create fail!\"" , "/home/maarten/src/libreoffice/core/sc/source/ui/view/cellsh1.cxx" , 2924, __extension__ __PRETTY_FUNCTION__)); | |||
2925 | ScopedVclPtr<AbstractScDataPilotDatabaseDlg> pDataDlg( | |||
2926 | pFact->CreateScDataPilotDatabaseDlg(pTabViewShell->GetFrameWeld())); | |||
2927 | assert(pDataDlg && "Dialog create fail!")(static_cast <bool> (pDataDlg && "Dialog create fail!" ) ? void (0) : __assert_fail ("pDataDlg && \"Dialog create fail!\"" , "/home/maarten/src/libreoffice/core/sc/source/ui/view/cellsh1.cxx" , 2927, __extension__ __PRETTY_FUNCTION__)); | |||
2928 | if ( pDataDlg->Execute() == RET_OK ) | |||
2929 | { | |||
2930 | ScImportSourceDesc aImpDesc(&rDoc); | |||
2931 | pDataDlg->GetValues( aImpDesc ); | |||
2932 | pNewDPObject.reset(new ScDPObject(&rDoc)); | |||
2933 | pNewDPObject->SetImportDesc( aImpDesc ); | |||
2934 | } | |||
2935 | } | |||
2936 | else if (pTypeDlg->IsNamedRange()) | |||
2937 | { | |||
2938 | OUString aName = pTypeDlg->GetSelectedNamedRange(); | |||
2939 | ScSheetSourceDesc aShtDesc(&rDoc); | |||
2940 | aShtDesc.SetRangeName(aName); | |||
2941 | pSrcErrorId = aShtDesc.CheckSourceRange(); | |||
2942 | if (!pSrcErrorId) | |||
2943 | { | |||
2944 | pNewDPObject.reset(new ScDPObject(&rDoc)); | |||
2945 | pNewDPObject->SetSheetDesc(aShtDesc); | |||
2946 | } | |||
2947 | } | |||
2948 | else // selection | |||
2949 | { | |||
2950 | //! use database ranges (select before type dialog?) | |||
2951 | ScRange aRange; | |||
2952 | ScMarkType eType = GetViewData()->GetSimpleArea(aRange); | |||
2953 | if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE ) | |||
2954 | { | |||
2955 | // Shrink the range to the data area. | |||
2956 | SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col(); | |||
2957 | SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row(); | |||
2958 | if (rDoc.ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow)) | |||
2959 | { | |||
2960 | aRange.aStart.SetCol(nStartCol); | |||
2961 | aRange.aStart.SetRow(nStartRow); | |||
2962 | aRange.aEnd.SetCol(nEndCol); | |||
2963 | aRange.aEnd.SetRow(nEndRow); | |||
2964 | rMark.SetMarkArea(aRange); | |||
2965 | pTabViewShell->MarkRange(aRange); | |||
2966 | } | |||
2967 | ||||
2968 | bool bOK = true; | |||
2969 | if ( rDoc.HasSubTotalCells( aRange ) ) | |||
2970 | { | |||
2971 | // confirm selection if it contains SubTotal cells | |||
2972 | std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(), | |||
2973 | VclMessageType::Question, VclButtonsType::YesNo, | |||
2974 | ScResId(STR_DATAPILOT_SUBTOTALreinterpret_cast<char const *>("STR_DATAPILOT_SUBTOTAL" "\004" u8"The source range contains subtotals which may distort the results. Use it anyway?" )))); | |||
2975 | xQueryBox->set_default_response(RET_YES); | |||
2976 | if (xQueryBox->run() == RET_NO) | |||
2977 | bOK = false; | |||
2978 | } | |||
2979 | if (bOK) | |||
2980 | { | |||
2981 | ScSheetSourceDesc aShtDesc(&rDoc); | |||
2982 | aShtDesc.SetSourceRange(aRange); | |||
2983 | pSrcErrorId = aShtDesc.CheckSourceRange(); | |||
2984 | if (!pSrcErrorId) | |||
2985 | { | |||
2986 | pNewDPObject.reset(new ScDPObject(&rDoc)); | |||
2987 | pNewDPObject->SetSheetDesc( aShtDesc ); | |||
2988 | } | |||
2989 | ||||
2990 | // output below source data | |||
2991 | if ( aRange.aEnd.Row()+2 <= rDoc.MaxRow() - 4 ) | |||
2992 | aDestPos = ScAddress( aRange.aStart.Col(), | |||
2993 | aRange.aEnd.Row()+2, | |||
2994 | aRange.aStart.Tab() ); | |||
2995 | } | |||
2996 | } | |||
2997 | } | |||
2998 | } | |||
2999 | ||||
3000 | if (pSrcErrorId) | |||
3001 | { | |||
3002 | // Error occurred during data creation. Launch an error and bail out. | |||
3003 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pTabViewShell->GetFrameWeld(), | |||
3004 | VclMessageType::Info, VclButtonsType::Ok, | |||
3005 | ScResId(pSrcErrorId))); | |||
3006 | xInfoBox->run(); | |||
3007 | return; | |||
3008 | } | |||
3009 | ||||
3010 | if ( pNewDPObject ) | |||
3011 | pNewDPObject->SetOutRange( aDestPos ); | |||
3012 | } | |||
3013 | ||||
3014 | bool bHadNewDPObject = pNewDPObject != nullptr; | |||
3015 | pTabViewShell->SetDialogDPObject( std::move(pNewDPObject) ); | |||
3016 | if ( bHadNewDPObject ) | |||
3017 | { | |||
3018 | // start layout dialog | |||
3019 | ||||
3020 | sal_uInt16 nId = ScPivotLayoutWrapper::GetChildWindowId(); | |||
3021 | SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame(); | |||
3022 | SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId ); | |||
3023 | pScMod->SetRefDialog( nId, pWnd == nullptr ); | |||
3024 | } | |||
3025 | } | |||
3026 | ||||
3027 | void ScCellShell::ExecuteXMLSourceDialog() | |||
3028 | { | |||
3029 | ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); | |||
3030 | if (!pTabViewShell) | |||
3031 | return; | |||
3032 | ||||
3033 | ScModule* pScMod = SC_MOD()( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule ::Calc)) ); | |||
3034 | ||||
3035 | sal_uInt16 nId = ScXMLSourceDlgWrapper::GetChildWindowId(); | |||
3036 | SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame(); | |||
3037 | SfxChildWindow* pWnd = pViewFrame->GetChildWindow(nId); | |||
3038 | pScMod->SetRefDialog(nId, pWnd == nullptr); | |||
3039 | } | |||
3040 | ||||
3041 | void ScCellShell::ExecuteSubtotals(SfxRequest& rReq) | |||
3042 | { | |||
3043 | ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell(); | |||
3044 | const SfxItemSet* pArgs = rReq.GetArgs(); | |||
3045 | if ( pArgs ) | |||
3046 | { | |||
3047 | pTabViewShell->DoSubTotals( static_cast<const ScSubTotalItem&>( pArgs->Get( SCITEM_SUBTDATA1104 )). | |||
3048 | GetSubTotalData() ); | |||
3049 | rReq.Done(); | |||
3050 | return; | |||
3051 | } | |||
3052 | ||||
3053 | ScopedVclPtr<SfxAbstractTabDialog> pDlg; | |||
3054 | ScSubTotalParam aSubTotalParam; | |||
3055 | SfxItemSet aArgSet( GetPool(), svl::Items<SCITEM_SUBTDATA1104, SCITEM_SUBTDATA1104>{} ); | |||
3056 | ||||
3057 | bool bAnonymous; | |||
3058 | ||||
3059 | // Only get existing named database range. | |||
3060 | ScDBData* pDBData = pTabViewShell->GetDBData(true, SC_DB_OLD); | |||
3061 | if (pDBData) | |||
3062 | bAnonymous = false; | |||
3063 | else | |||
3064 | { | |||
3065 | // No existing DB data at this position. Create an | |||
3066 | // anonymous DB. | |||
3067 | bAnonymous = true; | |||
3068 | pDBData = pTabViewShell->GetAnonymousDBData(); | |||
3069 | ScRange aDataRange; | |||
3070 | pDBData->GetArea(aDataRange); | |||
3071 | pTabViewShell->MarkRange(aDataRange, false); | |||
3072 | } | |||
3073 | ||||
3074 | pDBData->GetSubTotalParam( aSubTotalParam ); | |||
3075 | aSubTotalParam.bRemoveOnly = false; | |||
3076 | if (bAnonymous) | |||
3077 | { | |||
3078 | // Preset sort formatting along with values and also create formula | |||
3079 | // cells with "needs formatting". Subtotals on data of different types | |||
3080 | // doesn't make much sense anyway. | |||
3081 | aSubTotalParam.bIncludePattern = true; | |||
3082 | } | |||
3083 | ||||
3084 | aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA1104, GetViewData(), &aSubTotalParam ) ); | |||
3085 | ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); | |||
3086 | pDlg.disposeAndReset(pFact->CreateScSubTotalDlg(pTabViewShell->GetFrameWeld(), &aArgSet)); | |||
3087 | pDlg->SetCurPageId("1stgroup"); | |||
3088 | ||||
3089 | short bResult = pDlg->Execute(); | |||
3090 | ||||
3091 | if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE0x42) ) | |||
3092 | { | |||
3093 | const SfxItemSet* pOutSet = nullptr; | |||
3094 | ||||
3095 | if ( bResult == RET_OK ) | |||
3096 | { | |||
3097 | pOutSet = pDlg->GetOutputItemSet(); | |||
3098 | aSubTotalParam = | |||
3099 | static_cast<const ScSubTotalItem&>( | |||
3100 | pOutSet->Get( SCITEM_SUBTDATA1104 )). | |||
3101 | GetSubTotalData(); | |||
3102 | } | |||
3103 | else // if (bResult == SCRET_REMOVE) | |||
3104 | { | |||
3105 | pOutSet = &aArgSet; | |||
3106 | aSubTotalParam.bRemoveOnly = true; | |||
3107 | aSubTotalParam.bReplace = true; | |||
3108 | aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA1104, | |||
3109 | GetViewData(), | |||
3110 | &aSubTotalParam ) ); | |||
3111 | } | |||
3112 | ||||
3113 | pTabViewShell->DoSubTotals( aSubTotalParam ); | |||
3114 | rReq.Done( *pOutSet ); | |||
3115 | } | |||
3116 | else | |||
3117 | GetViewData()->GetDocShell()->CancelAutoDBRange(); | |||
3118 | } | |||
3119 | ||||
3120 | void ScCellShell::ExecuteFillSingleEdit() | |||
3121 | { | |||
3122 | ScAddress aCurPos = GetViewData()->GetCurPos(); | |||
3123 | ||||
3124 | OUString aInit; | |||
3125 | ||||
3126 | if (aCurPos.Row() > 0) | |||
3127 | { | |||
3128 | // Get the initial text value from the above cell. | |||
3129 | ||||
3130 | ScDocument& rDoc = GetViewData()->GetDocument(); | |||
3131 | ScAddress aPrevPos = aCurPos; | |||
3132 | aPrevPos.IncRow(-1); | |||
3133 | ScRefCellValue aCell(rDoc, aPrevPos); | |||
3134 | ||||
3135 | if (aCell.meType == CELLTYPE_FORMULA) | |||
3136 | { | |||
3137 | aInit = "="; | |||
3138 | const ScTokenArray* pCode = aCell.mpFormula->GetCode(); | |||
3139 | sc::TokenStringContext aCxt(rDoc, rDoc.GetGrammar()); | |||
3140 | aInit += pCode->CreateString(aCxt, aCurPos); | |||
3141 | } | |||
3142 | else | |||
3143 | aInit = aCell.getString(&rDoc); | |||
3144 | } | |||
3145 | ||||
3146 | SC_MOD()( static_cast<ScModule*>(SfxApplication::GetModule(SfxToolsModule ::Calc)) )->SetInputMode(SC_INPUT_TABLE, &aInit); | |||
3147 | } | |||
3148 | ||||
3149 | CellShell_Impl::CellShell_Impl() : | |||
3150 | m_pLinkedDlg(), | |||
3151 | m_pRequest( nullptr ) {} | |||
3152 | ||||
3153 | CellShell_Impl::~CellShell_Impl() | |||
3154 | { | |||
3155 | } | |||
3156 | /* 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 |