LibreOffice Module sc (master) 1
cellsh2.cxx
Go to the documentation of this file.
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 <basic/sberrors.hxx>
23#include <scitems.hxx>
24#include <comphelper/lok.hxx>
25#include <sfx2/viewfrm.hxx>
26#include <sfx2/request.hxx>
27#include <basic/sbxcore.hxx>
28#include <svl/whiter.hxx>
29#include <svl/numformat.hxx>
30#include <svl/zforlist.hxx>
31#include <svl/stritem.hxx>
32#include <svl/visitem.hxx>
34
35#include <com/sun/star/frame/FrameSearchFlag.hpp>
36#include <com/sun/star/sheet/TableValidationVisibility.hpp>
37
38#include <cellsh.hxx>
39#include <dbdata.hxx>
40#include <queryparam.hxx>
41#include <tabvwsh.hxx>
42#include <sc.hrc>
43#include <globstr.hrc>
44#include <scresid.hxx>
45#include <global.hxx>
46#include <scmod.hxx>
47#include <docsh.hxx>
48#include <document.hxx>
49#include <uiitems.hxx>
50#include <dbdocfun.hxx>
51#include <reffact.hxx>
52#include <utility>
53#include <validat.hxx>
54#include <validate.hxx>
55#include <datamapper.hxx>
56
57#include <scui_def.hxx>
58#include <scabstdlg.hxx>
59#include <impex.hxx>
60#include <asciiopt.hxx>
61#include <datastream.hxx>
62#include <datastreamdlg.hxx>
63#include <dataproviderdlg.hxx>
64#include <queryentry.hxx>
65#include <markdata.hxx>
66#include <documentlinkmgr.hxx>
67#include <officecfg/Office/Common.hxx>
68
69#include <o3tl/make_shared.hxx>
70#include <memory>
71
72using namespace com::sun::star;
73
74static bool lcl_GetTextToColumnsRange( const ScViewData& rData, ScRange& rRange, bool bDoEmptyCheckOnly )
75{
76 bool bRet = false;
77 const ScMarkData& rMark = rData.GetMarkData();
78
79 if ( rMark.IsMarked() )
80 {
81 if ( !rMark.IsMultiMarked() )
82 {
83 rRange = rMark.GetMarkArea();
84 if ( rRange.aStart.Col() == rRange.aEnd.Col() )
85 {
86 bRet = true;
87 }
88 }
89 }
90 else
91 {
92 const SCCOL nCol = rData.GetCurX();
93 const SCROW nRow = rData.GetCurY();
94 const SCTAB nTab = rData.GetTabNo();
95 rRange = ScRange( nCol, nRow, nTab, nCol, nRow, nTab );
96 bRet = true;
97 }
98
99 const ScDocument& rDoc = rData.GetDocument();
100
101 if ( bDoEmptyCheckOnly )
102 {
103 if ( bRet && rDoc.IsBlockEmpty( rRange.aStart.Col(), rRange.aStart.Row(),
104 rRange.aEnd.Col(), rRange.aEnd.Row(),
105 rRange.aStart.Tab() ) )
106 {
107 bRet = false;
108 }
109 }
110 else if ( bRet )
111 {
112 rRange.PutInOrder();
113 SCCOL nStartCol = rRange.aStart.Col(), nEndCol = rRange.aEnd.Col();
114 SCROW nStartRow = rRange.aStart.Row(), nEndRow = rRange.aEnd.Row();
115 bool bShrunk = false;
116 rDoc.ShrinkToUsedDataArea( bShrunk, rRange.aStart.Tab(), nStartCol, nStartRow,
117 nEndCol, nEndRow, false, false, true );
118 if ( bShrunk )
119 {
120 rRange.aStart.SetRow( nStartRow );
121 rRange.aEnd.SetRow( nEndRow );
122 }
123 }
124
125 return bRet;
126}
127
128static bool lcl_GetSortParam( const ScViewData& rData, const ScSortParam& rSortParam )
129{
130 ScTabViewShell* pTabViewShell = rData.GetViewShell();
131 ScDBData* pDBData = pTabViewShell->GetDBData();
132 ScDocument& rDoc = rData.GetDocument();
133 SCTAB nTab = rData.GetTabNo();
134 ScDirection eFillDir = DIR_TOP;
135 bool bSort = true;
136 ScRange aExternalRange;
137
138 if( rSortParam.nCol1 != rSortParam.nCol2 )
139 eFillDir = DIR_LEFT;
140 if( rSortParam.nRow1 != rSortParam.nRow2 )
141 eFillDir = DIR_TOP;
142
143 if( rSortParam.nRow2 == rDoc.MaxRow() )
144 {
145 // Assume that user selected entire column(s), but cater for the
146 // possibility that the start row is not the first row.
147 SCSIZE nCount = rDoc.GetEmptyLinesInBlock( rSortParam.nCol1, rSortParam.nRow1, nTab,
148 rSortParam.nCol2, rSortParam.nRow2, nTab, eFillDir );
149 aExternalRange = ScRange( rSortParam.nCol1,
150 ::std::min( rSortParam.nRow1 + sal::static_int_cast<SCROW>( nCount ), rDoc.MaxRow()), nTab,
151 rSortParam.nCol2, rSortParam.nRow2, nTab);
152 aExternalRange.PutInOrder();
153 }
154 else if (rSortParam.nCol1 != rSortParam.nCol2 || rSortParam.nRow1 != rSortParam.nRow2)
155 {
156 // Preserve a preselected area.
157 aExternalRange = ScRange( rSortParam.nCol1, rSortParam.nRow1, nTab, rSortParam.nCol2, rSortParam.nRow2, nTab);
158 aExternalRange.PutInOrder();
159 }
160 else
161 aExternalRange = ScRange( rData.GetCurX(), rData.GetCurY(), nTab );
162
163 SCROW nStartRow = aExternalRange.aStart.Row();
164 SCCOL nStartCol = aExternalRange.aStart.Col();
165 SCROW nEndRow = aExternalRange.aEnd.Row();
166 SCCOL nEndCol = aExternalRange.aEnd.Col();
167 rDoc.GetDataArea( aExternalRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow, false, false );
168 aExternalRange.aStart.SetRow( nStartRow );
169 aExternalRange.aStart.SetCol( nStartCol );
170 aExternalRange.aEnd.SetRow( nEndRow );
171 aExternalRange.aEnd.SetCol( nEndCol );
172
173 // with LibreOfficeKit, don't try to interact with the user
175 ((rSortParam.nCol1 == rSortParam.nCol2 && aExternalRange.aStart.Col() != aExternalRange.aEnd.Col()) ||
176 (rSortParam.nRow1 == rSortParam.nRow2 && aExternalRange.aStart.Row() != aExternalRange.aEnd.Row())))
177 {
178 pTabViewShell->AddHighlightRange( aExternalRange,COL_LIGHTBLUE );
179 OUString aExtendStr( aExternalRange.Format(rDoc, ScRefFlags::VALID));
180
181 ScRange aCurrentRange( rSortParam.nCol1, rSortParam.nRow1, nTab, rSortParam.nCol2, rSortParam.nRow2, nTab );
182 OUString aCurrentStr(aCurrentRange.Format(rDoc, ScRefFlags::VALID));
183
185
186 ScopedVclPtr<AbstractScSortWarningDlg> pWarningDlg(pFact->CreateScSortWarningDlg(pTabViewShell->GetFrameWeld(), aExtendStr, aCurrentStr));
187 short bResult = pWarningDlg->Execute();
188 if( bResult == BTN_EXTEND_RANGE || bResult == BTN_CURRENT_SELECTION )
189 {
190 if( bResult == BTN_EXTEND_RANGE )
191 {
192 pTabViewShell->MarkRange( aExternalRange, false );
193 pDBData->SetArea( nTab, aExternalRange.aStart.Col(), aExternalRange.aStart.Row(), aExternalRange.aEnd.Col(), aExternalRange.aEnd.Row() );
194 }
195 }
196 else
197 {
198 bSort = false;
200 }
201
202 pTabViewShell->ClearHighlightRanges();
203 }
204 return bSort;
205}
206
207namespace
208{
209 // this registers the dialog which Find1RefWindow search for
210 class ScValidationRegisteredDlg
211 {
212 std::shared_ptr<SfxDialogController> m_xDlg;
213 public:
214 ScValidationRegisteredDlg(weld::Window* pParent, std::shared_ptr<SfxDialogController> xDlg)
215 : m_xDlg(std::move(xDlg))
216 {
217 SC_MOD()->RegisterRefController(static_cast<sal_uInt16>(ScValidationDlg::SLOTID), m_xDlg, pParent);
218 }
219 ~ScValidationRegisteredDlg()
220 {
221 m_xDlg->Close();
222 SC_MOD()->UnregisterRefController(static_cast<sal_uInt16>(ScValidationDlg::SLOTID), m_xDlg);
223 }
224 };
225}
226
228{
229 ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
230 sal_uInt16 nSlotId = rReq.GetSlot();
231 const SfxItemSet* pReqArgs = rReq.GetArgs();
232 ScModule* pScMod = SC_MOD();
233
234 pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
235
236 if ( GetViewData().HasEditView( GetViewData().GetActivePart() ) )
237 {
238 pScMod->InputEnterHandler();
239 pTabViewShell->UpdateInputHandler();
240 }
241
242 switch ( nSlotId )
243 {
244 case SID_VIEW_DATA_SOURCE_BROWSER:
245 {
246 // check if database beamer is open
247
248 SfxViewFrame& rViewFrame = pTabViewShell->GetViewFrame();
249 bool bWasOpen = false;
250 {
251 uno::Reference<frame::XFrame> xFrame = rViewFrame.GetFrame().GetFrameInterface();
252 uno::Reference<frame::XFrame> xBeamerFrame = xFrame->findFrame(
253 "_beamer",
254 frame::FrameSearchFlag::CHILDREN);
255 if ( xBeamerFrame.is() )
256 bWasOpen = true;
257 }
258
259 if ( bWasOpen )
260 {
261 // close database beamer: just forward to SfxViewFrame
262
263 rViewFrame.ExecuteSlot( rReq );
264 }
265 else
266 {
267 // show database beamer: SfxViewFrame call must be synchronous
268
269 rViewFrame.ExecuteSlot( rReq, false ); // false = synchronous
270
271 // select current database in database beamer
272
273 ScImportParam aImportParam;
274 ScDBData* pDBData = pTabViewShell->GetDBData(true,SC_DB_OLD); // don't create if none found
275 if (pDBData)
276 pDBData->GetImportParam( aImportParam );
277
278 ScDBDocFunc::ShowInBeamer( aImportParam, &pTabViewShell->GetViewFrame() );
279 }
280 rReq.Done(); // needed because it's a toggle slot
281 }
282 break;
283
284 case SID_REIMPORT_DATA:
285 {
286 bool bOk = false;
287 ScDBData* pDBData = pTabViewShell->GetDBData(true,SC_DB_OLD);
288 if (pDBData)
289 {
290 ScImportParam aImportParam;
291 pDBData->GetImportParam( aImportParam );
292 if (aImportParam.bImport && !pDBData->HasImportSelection())
293 {
294 pTabViewShell->ImportData( aImportParam );
295 pDBData->SetImportParam( aImportParam );
296 bOk = true;
297 }
298 }
299
300 if (!bOk && ! rReq.IsAPI() )
301 pTabViewShell->ErrorMessage(STR_REIMPORT_EMPTY);
302
303 if( bOk )
304 rReq.Done();
305 }
306 break;
307
308 case SID_REFRESH_DBAREA:
309 {
310 ScDBData* pDBData = pTabViewShell->GetDBData(true,SC_DB_OLD);
311 if (pDBData)
312 {
313 // repeat import like SID_REIMPORT_DATA
314
315 bool bContinue = true;
316 ScImportParam aImportParam;
317 pDBData->GetImportParam( aImportParam );
318 if (aImportParam.bImport && !pDBData->HasImportSelection())
319 {
320 bContinue = pTabViewShell->ImportData( aImportParam );
321 pDBData->SetImportParam( aImportParam );
322
323 // mark (size may have been changed)
324 ScRange aNewRange;
325 pDBData->GetArea(aNewRange);
326 pTabViewShell->MarkRange(aNewRange);
327 }
328
329 if ( bContinue ) // fail at import -> break
330 {
331 // internal operations, when any stored
332
333 if ( pDBData->HasQueryParam() || pDBData->HasSortParam() ||
334 pDBData->HasSubTotalParam() )
335 pTabViewShell->RepeatDB();
336
337 // pivot tables that have the range as data source
338
339 ScRange aRange;
340 pDBData->GetArea(aRange);
342 }
343 }
344 rReq.Done();
345 }
346 break;
347
348 case SID_SBA_BRW_INSERT:
349 {
350 OSL_FAIL( "Deprecated Slot" );
351 }
352 break;
353
354 case SID_DATA_FORM:
355 {
357
359 pTabViewShell->GetFrameWeld(), pTabViewShell));
360
361 pDlg->Execute();
362
363 rReq.Done();
364 }
365 break;
366
367 case SID_SUBTOTALS:
368 ExecuteSubtotals(rReq);
369 break;
370
371 case SID_SORT_DESCENDING:
372 case SID_SORT_ASCENDING:
373 {
374 //#i60401 ux-ctest: Calc does not support all users' strategies regarding sorting data
375 //the patch comes from maoyg
376 ScSortParam aSortParam;
377 ScDBData* pDBData = pTabViewShell->GetDBData();
378 ScViewData& rData = GetViewData();
379
380 pDBData->GetSortParam( aSortParam );
381
382 if( lcl_GetSortParam( rData, aSortParam ) )
383 {
384 SCCOL nCol = GetViewData().GetCurX();
385 SCCOL nTab = GetViewData().GetTabNo();
387
388 pDBData->GetSortParam( aSortParam );
389 bool bHasHeader = rDoc.HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, nTab );
390
391 if( nCol < aSortParam.nCol1 )
392 nCol = aSortParam.nCol1;
393 else if( nCol > aSortParam.nCol2 )
394 nCol = aSortParam.nCol2;
395
396 aSortParam.bHasHeader = bHasHeader;
397 aSortParam.bByRow = true;
398 aSortParam.bCaseSens = false;
399 aSortParam.bNaturalSort = false;
400 aSortParam.aDataAreaExtras.mbCellNotes = false;
401 aSortParam.aDataAreaExtras.mbCellDrawObjects = true;
402 aSortParam.aDataAreaExtras.mbCellFormats = true;
403 aSortParam.bInplace = true;
404 aSortParam.maKeyState[0].bDoSort = true;
405 aSortParam.maKeyState[0].nField = nCol;
406 aSortParam.maKeyState[0].bAscending = ( nSlotId == SID_SORT_ASCENDING );
407
408 for ( sal_uInt16 i=1; i<aSortParam.GetSortKeyCount(); i++ )
409 aSortParam.maKeyState[i].bDoSort = false;
410
411 pTabViewShell->UISort( aSortParam ); // subtotal when needed new
412
413 rReq.Done();
414 }
415 }
416 break;
417
418 case SID_SORT:
419 {
420 const SfxItemSet* pArgs = rReq.GetArgs();
421
422 //#i60401 ux-ctest: Calc does not support all users' strategies regarding sorting data
423 //the patch comes from maoyg
424
425 if ( pArgs ) // Basic
426 {
427 ScSortParam aSortParam;
428 ScDBData* pDBData = pTabViewShell->GetDBData();
429 ScViewData& rData = GetViewData();
430
431 pDBData->GetSortParam( aSortParam );
432
433 if( lcl_GetSortParam( rData, aSortParam ) )
434 {
436
437 pDBData->GetSortParam( aSortParam );
438 bool bHasHeader = rDoc.HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, rData.GetTabNo() );
439 if( bHasHeader )
440 aSortParam.bHasHeader = bHasHeader;
441
442 aSortParam.bInplace = true; // from Basic always
443
444 if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_BYROW ) )
445 aSortParam.bByRow = pItem->GetValue();
446 if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_HASHEADER ) )
447 aSortParam.bHasHeader = pItem->GetValue();
448 if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_CASESENS ) )
449 aSortParam.bCaseSens = pItem->GetValue();
450 if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_NATURALSORT ) )
451 aSortParam.bNaturalSort = pItem->GetValue();
452 if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_INCCOMMENTS ) )
453 aSortParam.aDataAreaExtras.mbCellNotes = pItem->GetValue();
454 if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_INCIMAGES ) )
455 aSortParam.aDataAreaExtras.mbCellDrawObjects = pItem->GetValue();
456 if ( const SfxBoolItem* pItem = pArgs->GetItemIfSet( SID_SORT_ATTRIBS ) )
457 aSortParam.aDataAreaExtras.mbCellFormats = pItem->GetValue();
458 if ( const SfxUInt16Item* pItem = pArgs->GetItemIfSet( SID_SORT_USERDEF ) )
459 {
460 sal_uInt16 nUserIndex = pItem->GetValue();
461 aSortParam.bUserDef = ( nUserIndex != 0 );
462 if ( nUserIndex )
463 aSortParam.nUserIndex = nUserIndex - 1; // Basic: 1-based
464 }
465
466 SCCOLROW nField0 = 0;
467 const SfxPoolItem* pItem = nullptr;
468 if ( pArgs->GetItemState( FN_PARAM_1, true, &pItem ) == SfxItemState::SET )
469 nField0 = static_cast<const SfxInt32Item*>(pItem)->GetValue();
470 aSortParam.maKeyState[0].bDoSort = ( nField0 != 0 );
471 aSortParam.maKeyState[0].nField = nField0 > 0 ? (nField0-1) : 0;
472 if ( pArgs->GetItemState( FN_PARAM_2, true, &pItem ) == SfxItemState::SET )
473 aSortParam.maKeyState[0].bAscending = static_cast<const SfxBoolItem*>(pItem)->GetValue();
474 SCCOLROW nField1 = 0;
475 if ( pArgs->GetItemState( FN_PARAM_3, true, &pItem ) == SfxItemState::SET )
476 nField1 = static_cast<const SfxInt32Item*>(pItem)->GetValue();
477 aSortParam.maKeyState[1].bDoSort = ( nField1 != 0 );
478 aSortParam.maKeyState[1].nField = nField1 > 0 ? (nField1-1) : 0;
479 if ( pArgs->GetItemState( FN_PARAM_4, true, &pItem ) == SfxItemState::SET )
480 aSortParam.maKeyState[1].bAscending = static_cast<const SfxBoolItem*>(pItem)->GetValue();
481 SCCOLROW nField2 = 0;
482 if ( pArgs->GetItemState( FN_PARAM_5, true, &pItem ) == SfxItemState::SET )
483 nField2 = static_cast<const SfxInt32Item*>(pItem)->GetValue();
484 aSortParam.maKeyState[2].bDoSort = ( nField2 != 0 );
485 aSortParam.maKeyState[2].nField = nField2 > 0 ? (nField2-1) : 0;
486 if ( pArgs->GetItemState( FN_PARAM_6, true, &pItem ) == SfxItemState::SET )
487 aSortParam.maKeyState[2].bAscending = static_cast<const SfxBoolItem*>(pItem)->GetValue();
488
489 // subtotal when needed new
490 pTabViewShell->UISort( aSortParam );
491 rReq.Done();
492 }
493 }
494 else
495 {
496 ScSortParam aSortParam;
497 ScDBData* pDBData = pTabViewShell->GetDBData();
498 ScViewData& rData = GetViewData();
499
500 pDBData->GetSortParam( aSortParam );
501
502 if( lcl_GetSortParam( rData, aSortParam ) )
503 {
506
507 pDBData->GetSortParam( aSortParam );
508 bool bHasHeader = rDoc.HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, rData.GetTabNo() );
509 if( bHasHeader )
510 aSortParam.bHasHeader = bHasHeader;
511
512 aArgSet.Put( ScSortItem( SCITEM_SORTDATA, &GetViewData(), &aSortParam ) );
513
515 std::shared_ptr<ScAsyncTabController> pDlg(pFact->CreateScSortDlg(pTabViewShell->GetFrameWeld(), &aArgSet));
516 pDlg->SetCurPageId("criteria"); // 1=sort field tab 2=sort options tab
517
519 aContext.maEndDialogFn = [pDlg, &rData, pTabViewShell](sal_Int32 nResult)
520 {
521 if ( nResult == RET_OK )
522 {
523 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
524 const ScSortParam& rOutParam =
525 pOutSet->Get( SCITEM_SORTDATA ).GetSortData();
526
527 // subtotal when needed new
528
529 pTabViewShell->UISort( rOutParam );
530
531 SfxViewFrame& rViewFrm = pTabViewShell->GetViewFrame();
532 SfxRequest aRequest(rViewFrm, SID_SORT);
533
534 if ( rOutParam.bInplace )
535 {
536 aRequest.AppendItem( SfxBoolItem( SID_SORT_BYROW,
537 rOutParam.bByRow ) );
538 aRequest.AppendItem( SfxBoolItem( SID_SORT_HASHEADER,
539 rOutParam.bHasHeader ) );
540 aRequest.AppendItem( SfxBoolItem( SID_SORT_CASESENS,
541 rOutParam.bCaseSens ) );
542 aRequest.AppendItem( SfxBoolItem( SID_SORT_NATURALSORT,
543 rOutParam.bNaturalSort ) );
544 aRequest.AppendItem( SfxBoolItem( SID_SORT_INCCOMMENTS,
545 rOutParam.aDataAreaExtras.mbCellNotes ) );
546 aRequest.AppendItem( SfxBoolItem( SID_SORT_INCIMAGES,
548 aRequest.AppendItem( SfxBoolItem( SID_SORT_ATTRIBS,
549 rOutParam.aDataAreaExtras.mbCellFormats ) );
550 sal_uInt16 nUser = rOutParam.bUserDef ? ( rOutParam.nUserIndex + 1 ) : 0;
551 aRequest.AppendItem( SfxUInt16Item( SID_SORT_USERDEF, nUser ) );
552 if ( rOutParam.maKeyState[0].bDoSort )
553 {
555 rOutParam.maKeyState[0].nField + 1 ) );
556 aRequest.AppendItem( SfxBoolItem( FN_PARAM_2,
557 rOutParam.maKeyState[0].bAscending ) );
558 }
559 if ( rOutParam.maKeyState[1].bDoSort )
560 {
562 rOutParam.maKeyState[1].nField + 1 ) );
563 aRequest.AppendItem( SfxBoolItem( FN_PARAM_4,
564 rOutParam.maKeyState[1].bAscending ) );
565 }
566 if ( rOutParam.maKeyState[2].bDoSort )
567 {
569 rOutParam.maKeyState[2].nField + 1 ) );
570 aRequest.AppendItem( SfxBoolItem( FN_PARAM_6,
571 rOutParam.maKeyState[2].bAscending ) );
572 }
573 }
574
575 aRequest.Done();
576 }
577 else
578 {
579 rData.GetDocShell()->CancelAutoDBRange();
580 }
581 };
582
583 pDlg->StartExecuteAsync(aContext);
584 }
585 }
586 }
587 break;
588
589 case SID_FILTER:
590 {
591 const SfxItemSet* pArgs = rReq.GetArgs();
592 if ( pArgs )
593 {
594 OSL_FAIL("SID_FILTER with arguments?");
595 pTabViewShell->Query(
596 pArgs->Get( SCITEM_QUERYDATA ).GetQueryData(), nullptr, true );
597 rReq.Done();
598 }
599 else
600 {
601 sal_uInt16 nId = ScFilterDlgWrapper::GetChildWindowId();
602 SfxViewFrame& rViewFrm = pTabViewShell->GetViewFrame();
603 SfxChildWindow* pWnd = rViewFrm.GetChildWindow( nId );
604
605 pScMod->SetRefDialog( nId, pWnd == nullptr );
606 }
607 }
608 break;
609
610 case SID_SPECIAL_FILTER:
611 {
612 const SfxItemSet* pArgs = rReq.GetArgs();
613 if ( pArgs )
614 {
615 OSL_FAIL("SID_SPECIAL_FILTER with arguments?");
616 pTabViewShell->Query(
617 pArgs->Get( SCITEM_QUERYDATA ).GetQueryData(), nullptr, true );
618 rReq.Done();
619 }
620 else
621 {
622 sal_uInt16 nId = ScSpecialFilterDlgWrapper::GetChildWindowId();
623 SfxViewFrame& rViewFrm = pTabViewShell->GetViewFrame();
624 SfxChildWindow* pWnd = rViewFrm.GetChildWindow( nId );
625
626 pScMod->SetRefDialog( nId, pWnd == nullptr );
627 }
628 }
629 break;
630
631 case FID_FILTER_OK:
632 {
633 const ScQueryItem* pQueryItem;
634 if ( pReqArgs && (pQueryItem =
635 pReqArgs->GetItemIfSet( SCITEM_QUERYDATA )) )
636 {
637 SCTAB nCurTab = GetViewData().GetTabNo();
638 SCTAB nRefTab = GetViewData().GetRefTabNo();
639
640 // If RefInput switched to a different sheet from the data sheet,
641 // switch back:
642
643 if ( nCurTab != nRefTab )
644 {
645 pTabViewShell->SetTabNo( nRefTab );
646 pTabViewShell->PaintExtras();
647 }
648
649 ScRange aAdvSource;
650 if (pQueryItem->GetAdvancedQuerySource(aAdvSource))
651 pTabViewShell->Query( pQueryItem->GetQueryData(), &aAdvSource, true );
652 else
653 pTabViewShell->Query( pQueryItem->GetQueryData(), nullptr, true );
654 rReq.Done( *pReqArgs );
655 }
656 }
657 break;
658
659 case SID_UNFILTER:
660 {
661 ScQueryParam aParam;
662 ScDBData* pDBData = pTabViewShell->GetDBData();
663
664 pDBData->GetQueryParam( aParam );
665 SCSIZE nEC = aParam.GetEntryCount();
666 for (SCSIZE i=0; i<nEC; i++)
667 aParam.GetEntry(i).bDoQuery = false;
668 aParam.bDuplicate = true;
669 pTabViewShell->Query( aParam, nullptr, true );
670 rReq.Done();
671 }
672 break;
673
674 case SID_AUTO_FILTER:
675 pTabViewShell->ToggleAutoFilter();
676 rReq.Done();
677 break;
678
679 case SID_AUTOFILTER_HIDE:
680 pTabViewShell->HideAutoFilter();
681 rReq.Done();
682 break;
683
684 case SID_PIVOT_TABLE:
685 {
686 const ScPivotItem* pPItem;
687 if ( pReqArgs && (pPItem =
688 pReqArgs->GetItemIfSet( SCITEM_PIVOTDATA )) )
689 {
690 SCTAB nCurTab = GetViewData().GetTabNo();
691 SCTAB nRefTab = GetViewData().GetRefTabNo();
692
693 // If RefInput switched to a different sheet from the data sheet,
694 // switch back:
695
696 if ( nCurTab != nRefTab )
697 {
698 pTabViewShell->SetTabNo( nRefTab );
699 pTabViewShell->PaintExtras();
700 }
701
702 const ScDPObject* pDPObject = pTabViewShell->GetDialogDPObject();
703 if ( pDPObject )
704 {
705 bool bSuccess = pTabViewShell->MakePivotTable(
706 pPItem->GetData(), pPItem->GetDestRange(), pPItem->IsNewSheet(), *pDPObject );
707 SfxBoolItem aRet(0, bSuccess);
708 rReq.SetReturnValue(aRet);
709 }
710 rReq.Done();
711 }
712#if HAVE_FEATURE_SCRIPTING
713 else if (rReq.IsAPI())
715#endif
716 }
717 break;
718
719 case SID_OPENDLG_PIVOTTABLE:
721 break;
722 case SID_DEFINE_DBNAME:
723 {
724
725 sal_uInt16 nId = ScDbNameDlgWrapper::GetChildWindowId();
726 SfxViewFrame& rViewFrm = pTabViewShell->GetViewFrame();
727 SfxChildWindow* pWnd = rViewFrm.GetChildWindow( nId );
728
729 pScMod->SetRefDialog( nId, pWnd == nullptr );
730
731 }
732 break;
733
734 case SID_SELECT_DB:
735 {
736 if ( pReqArgs )
737 {
738 const SfxStringItem& rItem = pReqArgs->Get(SID_SELECT_DB);
739 pTabViewShell->GotoDBArea(rItem.GetValue());
740 rReq.Done();
741 }
742 else
743 {
745 ScDBCollection* pDBCol = rDoc.GetDBCollection();
746
747 if ( pDBCol )
748 {
749 std::vector<OUString> aList;
750 const ScDBCollection::NamedDBs& rDBs = pDBCol->getNamedDBs();
751 for (const auto& rxDB : rDBs)
752 aList.push_back(rxDB->GetName());
753
755
756 ScopedVclPtr<AbstractScSelEntryDlg> pDlg(pFact->CreateScSelEntryDlg(pTabViewShell->GetFrameWeld(), aList));
757 if ( pDlg->Execute() == RET_OK )
758 {
759 OUString aName = pDlg->GetSelectedEntry();
760 pTabViewShell->GotoDBArea( aName );
761 rReq.AppendItem( SfxStringItem( SID_SELECT_DB, aName ) );
762 rReq.Done();
763 }
764 }
765 }
766 }
767 break;
768 case SID_DATA_STREAMS:
769 {
770 sc::DataStreamDlg aDialog(GetViewData().GetDocShell(), pTabViewShell->GetFrameWeld());
773 sc::DataStream* pStrm = rMgr.getDataStream();
774 if (pStrm)
775 aDialog.Init(*pStrm);
776
777 if (aDialog.run() == RET_OK)
778 aDialog.StartStream();
779 }
780 break;
781 case SID_DATA_STREAMS_PLAY:
782 {
785 sc::DataStream* pStrm = rMgr.getDataStream();
786 if (pStrm)
787 pStrm->StartImport();
788 }
789 break;
790 case SID_DATA_STREAMS_STOP:
791 {
794 sc::DataStream* pStrm = rMgr.getDataStream();
795 if (pStrm)
796 pStrm->StopImport();
797 }
798 break;
799 case SID_DATA_PROVIDER:
800 {
801 auto xDoc = o3tl::make_shared<ScDocument>();
802 xDoc->InsertTab(0, "test");
804 ScDataProviderDlg aDialog(pTabViewShell->GetDialogParent(), xDoc, &rDoc);
805 if (aDialog.run() == RET_OK)
806 {
807 aDialog.import(rDoc);
808 }
809 }
810 break;
811 case SID_DATA_PROVIDER_REFRESH:
812 {
814 auto& rDataMapper = rDoc.GetExternalDataMapper();
815 for (auto& rDataSource : rDataMapper.getDataSources())
816 {
817 rDataSource.refresh(&rDoc, false);
818 }
819 }
820 break;
821 case SID_MANAGE_XML_SOURCE:
823 break;
824 case FID_VALIDATION:
825 case FID_CURRENTVALIDATION:
826 {
827 const SfxItemSet* pArgs = rReq.GetArgs();
828 if ( pArgs )
829 {
830 OSL_FAIL("later...");
831 }
832 else
833 {
837 OUString aExpr1, aExpr2;
838 bool bBlank = true;
839 sal_Int16 nListType = css::sheet::TableValidationVisibility::UNSORTED;
840 bool bShowHelp = false;
841 OUString aHelpTitle, aHelpText;
842 bool bShowError = false;
844 OUString aErrTitle, aErrText;
845
847 SCCOL nCurX = GetViewData().GetCurX();
848 SCROW nCurY = GetViewData().GetCurY();
849 SCTAB nTab = GetViewData().GetTabNo();
850 ScAddress aCursorPos( nCurX, nCurY, nTab );
851 sal_uInt32 nIndex = rDoc.GetAttr(
852 nCurX, nCurY, nTab, ATTR_VALIDDATA )->GetValue();
853 if ( nIndex )
854 {
855 const ScValidationData* pOldData = rDoc.GetValidationEntry( nIndex );
856 if ( pOldData )
857 {
858 eMode = pOldData->GetDataMode();
859 eOper = pOldData->GetOperation();
860 sal_uInt32 nNumFmt = 0;
861 if ( eMode == SC_VALID_DATE || eMode == SC_VALID_TIME )
862 {
863 SvNumFormatType nType = ( eMode == SC_VALID_DATE ) ? SvNumFormatType::DATE
864 : SvNumFormatType::TIME;
865 nNumFmt = rDoc.GetFormatTable()->GetStandardFormat(
867 }
868 aExpr1 = pOldData->GetExpression( aCursorPos, 0, nNumFmt );
869 aExpr2 = pOldData->GetExpression( aCursorPos, 1, nNumFmt );
870 bBlank = pOldData->IsIgnoreBlank();
871 nListType = pOldData->GetListType();
872
873 bShowHelp = pOldData->GetInput( aHelpTitle, aHelpText );
874 bShowError = pOldData->GetErrMsg( aErrTitle, aErrText, eErrStyle );
875
876 aArgSet.Put( SfxUInt16Item( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>(eMode) ) );
877 aArgSet.Put( SfxUInt16Item( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>(eOper) ) );
878 aArgSet.Put( SfxStringItem( FID_VALID_VALUE1, aExpr1 ) );
879 aArgSet.Put( SfxStringItem( FID_VALID_VALUE2, aExpr2 ) );
880 aArgSet.Put( SfxBoolItem( FID_VALID_BLANK, bBlank ) );
881 aArgSet.Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) );
882 aArgSet.Put( SfxBoolItem( FID_VALID_SHOWHELP, bShowHelp ) );
883 aArgSet.Put( SfxStringItem( FID_VALID_HELPTITLE, aHelpTitle ) );
884 aArgSet.Put( SfxStringItem( FID_VALID_HELPTEXT, aHelpText ) );
885 aArgSet.Put( SfxBoolItem( FID_VALID_SHOWERR, bShowError ) );
886 aArgSet.Put( SfxUInt16Item( FID_VALID_ERRSTYLE, sal::static_int_cast<sal_uInt16>(eErrStyle) ) );
887 aArgSet.Put( SfxStringItem( FID_VALID_ERRTITLE, aErrTitle ) );
888 aArgSet.Put( SfxStringItem( FID_VALID_ERRTEXT, aErrText ) );
889 }
890 }
891
892 // cell range picker
894 weld::Window* pParentWin = pWin ? pWin->GetFrameWeld() : nullptr;
895 auto xDlg = std::make_shared<ScValidationDlg>(pParentWin, &aArgSet, pTabViewShell);
896 ScValidationRegisteredDlg aRegisterThatDlgExists(pParentWin, xDlg);
897
898 short nResult = xDlg->run();
899 if ( nResult == RET_OK )
900 {
901 const SfxItemSet* pOutSet = xDlg->GetOutputItemSet();
902
903 if ( const SfxUInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_MODE ) )
904 eMode = static_cast<ScValidationMode>(pItem->GetValue());
905 if ( const SfxUInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_CONDMODE ) )
906 eOper = static_cast<ScConditionMode>(pItem->GetValue());
907 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_VALUE1 ) )
908 {
909 OUString aTemp1 = pItem->GetValue();
911 {
912 sal_uInt32 nNumIndex = 0;
913 double nVal;
914 if (rDoc.GetFormatTable()->IsNumberFormat(aTemp1, nNumIndex, nVal))
915 aExpr1 = ::rtl::math::doubleToUString( nVal,
916 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
918 else
919 aExpr1 = aTemp1;
920 }
921 else
922 aExpr1 = aTemp1;
923 }
924 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_VALUE2 ) )
925 {
926 OUString aTemp2 = pItem->GetValue();
928 {
929 sal_uInt32 nNumIndex = 0;
930 double nVal;
931 if (rDoc.GetFormatTable()->IsNumberFormat(aTemp2, nNumIndex, nVal))
932 aExpr2 = ::rtl::math::doubleToUString( nVal,
933 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
935 else
936 aExpr2 = aTemp2;
937 if ( eMode == SC_VALID_TIME ) {
938 sal_Int32 wraparound = aExpr1.compareTo(aExpr2);
939 if (wraparound > 0) {
940 if (eOper == ScConditionMode::Between) {
942 std::swap( aExpr1, aExpr2 );
943 }
944 else if (eOper == ScConditionMode::NotBetween) {
946 std::swap( aExpr1, aExpr2 );
947 }
948 }
949 }
950 }
951 else
952 aExpr2 = aTemp2;
953 }
954 if ( const SfxBoolItem* pItem = pOutSet->GetItemIfSet( FID_VALID_BLANK ) )
955 bBlank = pItem->GetValue();
956 if ( const SfxInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_LISTTYPE ) )
957 nListType = pItem->GetValue();
958
959 if ( const SfxBoolItem* pItem = pOutSet->GetItemIfSet( FID_VALID_SHOWHELP ) )
960 bShowHelp = pItem->GetValue();
961 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_HELPTITLE ) )
962 aHelpTitle = pItem->GetValue();
963 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_HELPTEXT ) )
964 aHelpText = pItem->GetValue();
965
966 if ( const SfxBoolItem* pItem = pOutSet->GetItemIfSet( FID_VALID_SHOWERR ) )
967 bShowError = pItem->GetValue();
968 if ( const SfxUInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_ERRSTYLE ) )
969 eErrStyle = static_cast<ScValidErrorStyle>(pItem->GetValue());
970 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_ERRTITLE ) )
971 aErrTitle = pItem->GetValue();
972 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_ERRTEXT ) )
973 aErrText = pItem->GetValue();
974
975 ScValidationData aData( eMode, eOper, aExpr1, aExpr2, rDoc, aCursorPos );
976 aData.SetIgnoreBlank( bBlank );
977 aData.SetListType( nListType );
978
979 aData.SetInput(aHelpTitle, aHelpText); // sets bShowInput to TRUE
980 if (!bShowHelp)
981 aData.ResetInput(); // reset only bShowInput
982
983 aData.SetError(aErrTitle, aErrText, eErrStyle); // sets bShowError to TRUE
984 if (!bShowError)
985 aData.ResetError(); // reset only bShowError
986
987 pTabViewShell->SetValidation( aData );
988 pTabViewShell->TestHintWindow();
989 rReq.Done( *pOutSet );
990 }
991 }
992 }
993 break;
994
995 case SID_TEXT_TO_COLUMNS:
996 {
997 ScViewData& rData = GetViewData();
998 ScRange aRange;
999
1000 if ( lcl_GetTextToColumnsRange( rData, aRange, false ) )
1001 {
1002 ScDocument& rDoc = rData.GetDocument();
1003
1004 ScImportExport aExport( rDoc, aRange );
1006
1007 // #i87703# text to columns fails with tab separator
1008 aExport.SetDelimiter( u'\0' );
1009
1010 SvMemoryStream aStream;
1011 aStream.SetStreamCharSet( RTL_TEXTENCODING_UNICODE );
1013 aExport.ExportStream( aStream, OUString(), SotClipboardFormatId::STRING );
1014
1017 pTabViewShell->GetFrameWeld(), OUString(), &aStream, SC_TEXTTOCOLUMNS));
1018
1019 if ( pDlg->Execute() == RET_OK )
1020 {
1021 ScDocShell* pDocSh = rData.GetDocShell();
1022 OSL_ENSURE( pDocSh, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDocSh is null!" );
1023
1024 OUString aUndo = ScResId( STR_UNDO_TEXTTOCOLUMNS );
1025 pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, rData.GetViewShell()->GetViewShellId() );
1026
1027 ScImportExport aImport( rDoc, aRange.aStart );
1028 ScAsciiOptions aOptions;
1029 pDlg->GetOptions( aOptions );
1030 pDlg->SaveParameters();
1031 aImport.SetExtOptions( aOptions );
1032 aImport.SetApi( false );
1033 aImport.SetImportBroadcast( true );
1034 aImport.SetOverwriting( true );
1035 aStream.Seek( 0 );
1036 aImport.ImportStream( aStream, OUString(), SotClipboardFormatId::STRING );
1037
1038 pDocSh->GetUndoManager()->LeaveListAction();
1039 }
1040 }
1041 }
1042 break;
1043 }
1044}
1045
1047{
1048 ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
1049 ScViewData& rData = GetViewData();
1050 ScDocShell* pDocSh = rData.GetDocShell();
1051 ScDocument& rDoc = pDocSh->GetDocument();
1052 SCCOL nPosX = rData.GetCurX();
1053 SCROW nPosY = rData.GetCurY();
1054 SCTAB nTab = rData.GetTabNo();
1055
1056 bool bAutoFilter = false;
1057 bool bAutoFilterTested = false;
1058
1059 SfxWhichIter aIter(rSet);
1060 sal_uInt16 nWhich = aIter.FirstWhich();
1061 while (nWhich)
1062 {
1063 switch (nWhich)
1064 {
1065 case SID_REFRESH_DBAREA:
1066 {
1067 // imported data without selection
1068 // or filter,sort,subtotal (also without import)
1069 bool bOk = false;
1070 ScDBData* pDBData = pTabViewShell->GetDBData(false,SC_DB_OLD);
1071 if (pDBData && rDoc.GetChangeTrack() == nullptr)
1072 {
1073 if ( pDBData->HasImportParam() )
1074 bOk = !pDBData->HasImportSelection();
1075 else
1076 {
1077 bOk = pDBData->HasQueryParam() ||
1078 pDBData->HasSortParam() ||
1079 pDBData->HasSubTotalParam();
1080 }
1081 }
1082 if (!bOk)
1083 rSet.DisableItem( nWhich );
1084 }
1085 break;
1086
1087 case SID_FILTER:
1088 case SID_SPECIAL_FILTER:
1089 {
1090 ScRange aDummy;
1091 ScMarkType eMarkType = GetViewData().GetSimpleArea( aDummy);
1092 if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
1093 {
1094 rSet.DisableItem( nWhich );
1095 }
1096 }
1097 break;
1098
1099 //in case of Redlining and multiselection disable
1100 case SID_SORT_ASCENDING:
1101 case SID_SORT_DESCENDING:
1102 case SCITEM_SORTDATA:
1103 case SCITEM_SUBTDATA:
1104 case SID_OPENDLG_PIVOTTABLE:
1105 {
1107
1108 if ( pDocSh->IsReadOnly() || rDoc.GetChangeTrack()!=nullptr ||
1109 GetViewData().IsMultiMarked() )
1110 {
1111 rSet.DisableItem( nWhich );
1112 }
1113 }
1114 break;
1115
1116 case SID_REIMPORT_DATA:
1117 {
1118 // only imported data without selection
1119 ScDBData* pDBData = pTabViewShell->GetDBData(false,SC_DB_OLD);
1120 if (!pDBData || !pDBData->HasImportParam() || pDBData->HasImportSelection() ||
1121 rDoc.GetChangeTrack()!=nullptr)
1122 {
1123 rSet.DisableItem( nWhich );
1124 }
1125 }
1126 break;
1127
1128 case SID_VIEW_DATA_SOURCE_BROWSER:
1129 {
1130 if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::DATABASE))
1131 rSet.Put(SfxVisibilityItem(nWhich, false));
1132 else
1133 // get state (BoolItem) from SfxViewFrame
1134 pTabViewShell->GetViewFrame().GetSlotState( nWhich, nullptr, &rSet );
1135 }
1136 break;
1137 case SID_SBA_BRW_INSERT:
1138 {
1139 // SBA wants a sal_Bool-item, enabled
1140
1141 rSet.Put(SfxBoolItem(nWhich, true));
1142 }
1143 break;
1144
1145 case SID_AUTO_FILTER:
1146 case SID_AUTOFILTER_HIDE:
1147 {
1148 if (!bAutoFilterTested)
1149 {
1150 bAutoFilter = rDoc.HasAutoFilter( nPosX, nPosY, nTab );
1151 bAutoFilterTested = true;
1152 }
1153 if ( nWhich == SID_AUTO_FILTER )
1154 {
1155 ScRange aDummy;
1156 ScMarkType eMarkType = GetViewData().GetSimpleArea( aDummy);
1157 if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
1158 {
1159 rSet.DisableItem( nWhich );
1160 }
1161 else if (rDoc.GetDPAtBlock(aDummy))
1162 {
1163 rSet.DisableItem( nWhich );
1164 }
1165 else
1166 rSet.Put( SfxBoolItem( nWhich, bAutoFilter ) );
1167 }
1168 else
1169 if (!bAutoFilter)
1170 rSet.DisableItem( nWhich );
1171 }
1172 break;
1173
1174 case SID_UNFILTER:
1175 {
1176 SCCOL nStartCol, nEndCol;
1177 SCROW nStartRow, nEndRow;
1178 SCTAB nStartTab, nEndTab;
1179 bool bAnyQuery = false;
1180
1181 bool bSelected = (GetViewData().GetSimpleArea(
1182 nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab )
1183 == SC_MARK_SIMPLE);
1184
1185 if ( bSelected )
1186 {
1187 if (nStartCol==nEndCol && nStartRow==nEndRow)
1188 bSelected = false;
1189 }
1190 else
1191 {
1192 nStartCol = GetViewData().GetCurX();
1193 nStartRow = GetViewData().GetCurY();
1194 nStartTab = GetViewData().GetTabNo();
1195 }
1196
1197 ScDBData* pDBData = bSelected
1198 ? rDoc.GetDBAtArea( nStartTab, nStartCol, nStartRow, nEndCol, nEndRow )
1199 : rDoc.GetDBAtCursor( nStartCol, nStartRow, nStartTab, ScDBDataPortion::AREA );
1200
1201 if ( pDBData )
1202 {
1203 ScQueryParam aParam;
1204 pDBData->GetQueryParam( aParam );
1205 if ( aParam.GetEntry(0).bDoQuery )
1206 bAnyQuery = true;
1207 }
1208
1209 if ( !bAnyQuery )
1210 rSet.DisableItem( nWhich );
1211 }
1212 break;
1213
1214 case SID_DEFINE_DBNAME:
1215 {
1216 if ( pDocSh->IsDocShared() )
1217 {
1218 rSet.DisableItem( nWhich );
1219 }
1220 }
1221 break;
1222 case SID_DATA_PROVIDER:
1223 break;
1224 case SID_DATA_PROVIDER_REFRESH:
1225 {
1226 ScDocument& rViewDoc = GetViewData().GetDocument();
1227 auto& rDataMapper = rViewDoc.GetExternalDataMapper();
1228 if (rDataMapper.getDataSources().empty())
1229 rSet.DisableItem(nWhich);
1230 }
1231 break;
1232 case SID_DATA_STREAMS:
1233 case SID_DATA_STREAMS_PLAY:
1234 case SID_DATA_STREAMS_STOP:
1235 {
1236 if ( !officecfg::Office::Common::Misc::ExperimentalMode::get() )
1237 rSet.DisableItem( nWhich );
1238 }
1239 break;
1240 case SID_TEXT_TO_COLUMNS:
1241 {
1242 ScRange aRange;
1243 if ( !lcl_GetTextToColumnsRange( rData, aRange, true ) )
1244 {
1245 rSet.DisableItem( nWhich );
1246 }
1247 }
1248 break;
1249 case SID_MANAGE_XML_SOURCE:
1250 break;
1251 }
1252 nWhich = aIter.NextWhich();
1253 }
1254}
1255
1256/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
@ SC_TEXTTOCOLUMNS
Definition: asciiopt.hxx:112
static bool lcl_GetTextToColumnsRange(const ScViewData &rData, ScRange &rRange, bool bDoEmptyCheckOnly)
Definition: cellsh2.cxx:74
static bool lcl_GetSortParam(const ScViewData &rData, const ScSortParam &rSortParam)
Definition: cellsh2.cxx:128
sal_Int32 GetValue() const
const OUString & GetValue() const
const OUString & getNumDecimalSep() const
static void SetError(ErrCode)
virtual VclPtr< AbstractScSelEntryDlg > CreateScSelEntryDlg(weld::Window *pParent, const std::vector< OUString > &rEntryList)=0
virtual VclPtr< AbstractScSortWarningDlg > CreateScSortWarningDlg(weld::Window *pParent, const OUString &rExtendText, const OUString &rCurrentText)=0
virtual std::shared_ptr< ScAsyncTabController > CreateScSortDlg(weld::Window *pParent, const SfxItemSet *pArgSet)=0
virtual VclPtr< AbstractScDataFormDlg > CreateScDataFormDlg(weld::Window *pParent, ScTabViewShell *pTabViewShell)=0
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
Definition: scabstdlg.cxx:37
virtual VclPtr< AbstractScImportAsciiDlg > CreateScImportAsciiDlg(weld::Window *pParent, const OUString &aDatName, SvStream *pInStream, ScImportAsciiCall eCall)=0
SCTAB Tab() const
Definition: address.hxx:283
void SetCol(SCCOL nColP)
Definition: address.hxx:291
SCROW Row() const
Definition: address.hxx:274
void SetRow(SCROW nRowP)
Definition: address.hxx:287
SCCOL Col() const
Definition: address.hxx:279
void GetDBState(SfxItemSet &rSet)
Definition: cellsh2.cxx:1046
void ExecuteDB(SfxRequest &rReq)
Definition: cellsh2.cxx:227
void ExecuteDataPilotDialog()
Definition: cellsh1.cxx:3166
void ExecuteSubtotals(SfxRequest &rReq)
Definition: cellsh1.cxx:3361
void ExecuteXMLSourceDialog()
Definition: cellsh1.cxx:3347
ScConditionMode GetOperation() const
Definition: conditio.hxx:369
bool IsIgnoreBlank() const
Definition: conditio.hxx:371
OUString GetExpression(const ScAddress &rCursor, sal_uInt16 nPos, sal_uInt32 nNumFmt=0, const formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT) const
Definition: conditio.cxx:1256
Stores global named database ranges.
Definition: dbdata.hxx:243
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:324
void GetImportParam(ScImportParam &rImportParam) const
Definition: dbdata.cxx:478
SC_DLLPUBLIC bool HasQueryParam() const
Definition: dbdata.cxx:522
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:298
void SetImportParam(const ScImportParam &rImportParam)
Definition: dbdata.cxx:488
bool HasSubTotalParam() const
Definition: dbdata.cxx:540
SC_DLLPUBLIC void GetSortParam(ScSortParam &rSortParam) const
Definition: dbdata.cxx:399
bool HasSortParam() const
Definition: dbdata.cxx:533
SC_DLLPUBLIC void GetQueryParam(ScQueryParam &rQueryParam) const
Definition: dbdata.cxx:422
bool HasImportSelection() const
Definition: dbdata.hxx:209
bool HasImportParam() const
Definition: dbdata.cxx:517
void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dbdata.cxx:320
static void ShowInBeamer(const ScImportParam &rParam, const SfxViewFrame *pFrame)
Definition: dbdocimp.cxx:72
bool MakePivotTable(const ScDPSaveData &rData, const ScRange &rDest, bool bNewTable, const ScDPObject &rSource)
Definition: dbfunc3.cxx:621
ScDBData * GetDBData(bool bMarkArea=true, ScGetDBMode eMode=SC_DB_MAKE, ScGetDBSelection eSel=ScGetDBSelection::Keep)
Definition: dbfunc.cxx:81
void HideAutoFilter()
Definition: dbfunc.cxx:414
void ToggleAutoFilter()
Definition: dbfunc.cxx:276
SC_DLLPUBLIC void Query(const ScQueryParam &rQueryParam, const ScRange *pAdvSource, bool bRecord)
Definition: dbfunc.cxx:234
void GotoDBArea(const OUString &rDBName)
Definition: dbfunc.cxx:54
void UISort(const ScSortParam &rSortParam)
Definition: dbfunc.cxx:186
void RepeatDB(bool bRecord=true)
Definition: dbfunc3.cxx:2113
bool ImportData(const ScImportParam &rParam)
Definition: dbfunc.cxx:451
void import(ScDocument &rDoc, bool bInternal=false)
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
void CancelAutoDBRange()
Definition: docsh5.cxx:369
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2968
void RefreshPivotTables(const ScRange &rSource)
Definition: docsh5.cxx:482
ScDPObject * GetDPAtBlock(const ScRange &rBlock) const
Definition: documen3.cxx:391
SC_DLLPUBLIC const ScValidationData * GetValidationEntry(sal_uInt32 nIndex) const
Definition: documen4.cxx:873
const ScDBData * GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const
Definition: documen3.cxx:322
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:893
SC_DLLPUBLIC const ScDBData * GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
Definition: documen3.cxx:338
bool ShrinkToUsedDataArea(bool &o_bShrunk, SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow, bool bColumnsOnly, bool bStickyTopRow=false, bool bStickyLeftCol=false, ScDataAreaExtras *pDataAreaExtras=nullptr) const
Shrink a range to only include used data area.
Definition: document.cxx:1049
SC_DLLPUBLIC sc::ExternalDataMapper & GetExternalDataMapper()
SC_DLLPUBLIC bool HasColHeader(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab)
Definition: documen3.cxx:1526
SC_DLLPUBLIC ScDBCollection * GetDBCollection() const
Definition: document.hxx:827
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
sc::DocumentLinkManager & GetDocLinkManager()
Definition: documen2.cxx:241
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2494
bool IsBlockEmpty(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const
Definition: document.cxx:5288
SC_DLLPUBLIC void GetDataArea(SCTAB nTab, SCCOL &rStartCol, SCROW &rStartRow, SCCOL &rEndCol, SCROW &rEndRow, bool bIncludeOld, bool bOnlyDown) const
Return the smallest area containing at least all contiguous cells having data.
Definition: document.cxx:1072
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4684
bool HasAutoFilter(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: documen3.cxx:1494
SC_DLLPUBLIC SCSIZE GetEmptyLinesInBlock(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, ScDirection eDir)
Definition: document.cxx:6067
ScViewData & GetViewData()
Definition: formatsh.hxx:34
static SC_DLLPUBLIC LanguageType eLnge
Definition: global.hxx:560
static SC_DLLPUBLIC const LocaleDataWrapper & getLocaleData()
Definition: global.cxx:1055
void SetApi(bool bApi)
Definition: impex.hxx:158
void SetExportTextOptions(const ScExportTextOptions &options)
Definition: impex.hxx:161
bool ExportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
Definition: impex.cxx:435
bool ImportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
Definition: impex.cxx:395
void SetImportBroadcast(bool b)
Definition: impex.hxx:159
void SetOverwriting(const bool bOverwriting)
Definition: impex.hxx:160
static void SetNoEndianSwap(SvStream &rStrm)
only if stream is only used in own (!) memory
Definition: impex.cxx:590
void SetExtOptions(const ScAsciiOptions &rOpt)
Definition: impex.cxx:207
void SetDelimiter(sal_Unicode c)
Definition: impex.hxx:134
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
const ScRange & GetMarkArea() const
Definition: markdata.hxx:83
bool IsMultiMarked() const
Definition: markdata.hxx:81
bool IsMarked() const
Definition: markdata.hxx:80
SC_DLLPUBLIC void SetRefDialog(sal_uInt16 nId, bool bVis, SfxViewFrame *pViewFrm=nullptr)
Reference dialogs.
Definition: scmod.cxx:1519
SC_DLLPUBLIC void InputEnterHandler(ScEnterMode nBlockMode=ScEnterMode::NORMAL, bool bBeforeSavingInLOK=false)
Definition: scmod.cxx:1411
bool IsNewSheet() const
Definition: uiitems.hxx:239
const ScDPSaveData & GetData() const
Definition: uiitems.hxx:237
const ScRange & GetDestRange() const
Definition: uiitems.hxx:238
bool GetAdvancedQuerySource(ScRange &rSource) const
Definition: uiitems.cxx:220
const ScQueryParam & GetQueryData() const
Definition: uiitems.cxx:215
OUString Format(const ScDocument &rDocument, ScRefFlags nFlags=ScRefFlags::ZERO, const ScAddress::Details &rDetails=ScAddress::detailsOOOa1, bool bFullAddressNotation=false) const
Returns string with formatted cell range from aStart to aEnd, according to provided address conventio...
Definition: address.cxx:2170
void PutInOrder()
Definition: address.hxx:622
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
static const WhichRangesContainer & GetRanges()
Definition: validate.hxx:84
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:690
const ScDPObject * GetDialogDPObject() const
Definition: tabvwsh.hxx:290
weld::Window * GetDialogParent()
parent window for dialogs Problem: OLE Server!
Definition: tabvwshd.cxx:31
void AddHighlightRange(const ScRange &rRange, const Color &rColor)
Definition: tabview3.cxx:2549
void TestHintWindow()
Definition: tabview3.cxx:780
void ErrorMessage(TranslateId pGlobStrId)
Definition: tabview2.cxx:1553
bool PaintExtras()
Definition: tabview3.cxx:2787
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1708
void ClearHighlightRanges()
Definition: tabview3.cxx:2559
void HideListBox()
Definition: tabview3.cxx:2996
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1819
ScValidationMode GetDataMode() const
Definition: validat.hxx:118
sal_Int16 GetListType() const
Definition: validat.hxx:120
bool GetInput(OUString &rTitle, OUString &rMsg) const
Definition: validat.hxx:112
bool GetErrMsg(OUString &rTitle, OUString &rMsg, ScValidErrorStyle &rStyle) const
Definition: validat.cxx:177
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3146
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3162
ScTabViewShell * GetViewShell() const
Definition: viewdata.hxx:357
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
Definition: viewdata.cxx:1182
SCTAB GetRefTabNo() const
Definition: viewdata.hxx:392
SCROW GetCurY() const
Definition: viewdata.hxx:402
SCCOL GetCurX() const
Definition: viewdata.hxx:401
void SetValidation(const ScValidationData &rNew)
Definition: viewfun2.cxx:3459
bool GetValue() const
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
bool IsReadOnly() const
bool IsDocShared() const
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
void AppendItem(const SfxPoolItem &)
void SetReturnValue(const SfxPoolItem &)
bool IsAPI() const
void Done(bool bRemove=false)
const SfxPoolItem * GetSlotState(sal_uInt16 nSlotId, const SfxInterface *pIF=nullptr, SfxItemSet *pStateSet=nullptr)
SfxItemPool & GetPool() const
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
size_t LeaveListAction()
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
SfxChildWindow * GetChildWindow(sal_uInt16)
SfxFrame & GetFrame() const
weld::Window * GetFrameWeld() const
ViewShellId GetViewShellId() const override
SfxViewFrame & GetViewFrame() const
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
bool IsNumberFormat(const OUString &sString, sal_uInt32 &F_Index, double &fOutNumber, SvNumInputOptions eInputOptions=SvNumInputOptions::NONE)
sal_uInt64 Seek(sal_uInt64 nPos)
void SetStreamCharSet(rtl_TextEncoding eCharSet)
void Init(const DataStream &rStrm)
void StartImport()
Definition: datastream.cxx:382
DataStream * getDataStream()
weld::Window * GetFrameWeld() const
virtual short run()
constexpr ::Color COL_LIGHTBLUE(0x00, 0x00, 0xFF)
ScConditionMode
Definition: conditio.hxx:60
int nCount
@ AREA
entire area
float u
ScDirection
Definition: global.hxx:343
@ DIR_LEFT
Definition: global.hxx:347
@ DIR_TOP
Definition: global.hxx:346
@ SC_DB_OLD
don't create
Definition: global.hxx:386
sal_Int32 nIndex
OUString aName
Mode eMode
constexpr OUStringLiteral aData
int i
sal_Int16 nId
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
#define ERRCODE_BASIC_BAD_PARAMETER
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
#define SCITEM_SORTDATA
Definition: scitems.hxx:90
#define SCITEM_SUBTDATA
Definition: scitems.hxx:92
#define SCITEM_PIVOTDATA
Definition: scitems.hxx:94
#define SCITEM_QUERYDATA
Definition: scitems.hxx:91
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALIDDATA(153)
#define SC_MOD()
Definition: scmod.hxx:247
#define BTN_EXTEND_RANGE
Definition: scui_def.hxx:65
#define BTN_CURRENT_SELECTION
Definition: scui_def.hxx:66
static SfxItemSet & rSet
bool mbCellDrawObjects
If TRUE, consider the presence of draw objects anchored to the cell.
Definition: sortparam.hxx:57
bool mbCellFormats
If TRUE, consider the presence of cell formats.
Definition: sortparam.hxx:59
bool mbCellNotes
If TRUE, consider the presence of cell notes besides data.
Definition: sortparam.hxx:55
These options control how multi-line cells are converted during export in certain lossy formats (such...
Definition: impex.hxx:38
bool bImport
Definition: global.hxx:445
SC_DLLPUBLIC const ScQueryEntry & GetEntry(SCSIZE n) const
Definition: queryparam.cxx:116
SC_DLLPUBLIC SCSIZE GetEntryCount() const
Definition: queryparam.cxx:111
bool bNaturalSort
Definition: sortparam.hxx:123
::std::vector< ScSortKeyState > maKeyState
Definition: sortparam.hxx:130
bool bHasHeader
Definition: sortparam.hxx:120
ScDataAreaExtras aDataAreaExtras
Definition: sortparam.hxx:118
sal_uInt16 nUserIndex
Definition: sortparam.hxx:119
sal_uInt16 GetSortKeyCount() const
Definition: sortparam.hxx:148
bool bCaseSens
Definition: sortparam.hxx:122
std::function< void(sal_Int32)> maEndDialogFn
Reference< XFrame > xFrame
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
ScValidationMode
Definition: validat.hxx:41
@ SC_VALID_TIME
Definition: validat.hxx:46
@ SC_VALID_ANY
Definition: validat.hxx:42
@ SC_VALID_DATE
Definition: validat.hxx:45
ScValidErrorStyle
Definition: validat.hxx:53
@ SC_VALERR_STOP
Definition: validat.hxx:54
RET_OK
ScMarkType
States GetSimpleArea() returns for the underlying selection marks, so the caller can react if the res...
Definition: viewdata.hxx:61
@ SC_MARK_SIMPLE
Definition: viewdata.hxx:65
@ SC_MARK_SIMPLE_FILTERED
Definition: viewdata.hxx:67
SvNumFormatType