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 {
554 aRequest.AppendItem( SfxInt32Item( FN_PARAM_1,
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 {
561 aRequest.AppendItem( SfxInt32Item( FN_PARAM_3,
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 {
568 aRequest.AppendItem( SfxInt32Item( FN_PARAM_5,
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
739 = static_cast<const SfxStringItem&>(pReqArgs->Get(SID_SELECT_DB));
740 pTabViewShell->GotoDBArea(rItem.GetValue());
741 rReq.Done();
742 }
743 else
744 {
746 ScDBCollection* pDBCol = rDoc.GetDBCollection();
747
748 if ( pDBCol )
749 {
750 std::vector<OUString> aList;
751 const ScDBCollection::NamedDBs& rDBs = pDBCol->getNamedDBs();
752 for (const auto& rxDB : rDBs)
753 aList.push_back(rxDB->GetName());
754
756
757 ScopedVclPtr<AbstractScSelEntryDlg> pDlg(pFact->CreateScSelEntryDlg(pTabViewShell->GetFrameWeld(), aList));
758 if ( pDlg->Execute() == RET_OK )
759 {
760 OUString aName = pDlg->GetSelectedEntry();
761 pTabViewShell->GotoDBArea( aName );
762 rReq.AppendItem( SfxStringItem( SID_SELECT_DB, aName ) );
763 rReq.Done();
764 }
765 }
766 }
767 }
768 break;
769 case SID_DATA_STREAMS:
770 {
771 sc::DataStreamDlg aDialog(GetViewData().GetDocShell(), pTabViewShell->GetFrameWeld());
774 sc::DataStream* pStrm = rMgr.getDataStream();
775 if (pStrm)
776 aDialog.Init(*pStrm);
777
778 if (aDialog.run() == RET_OK)
779 aDialog.StartStream();
780 }
781 break;
782 case SID_DATA_STREAMS_PLAY:
783 {
786 sc::DataStream* pStrm = rMgr.getDataStream();
787 if (pStrm)
788 pStrm->StartImport();
789 }
790 break;
791 case SID_DATA_STREAMS_STOP:
792 {
795 sc::DataStream* pStrm = rMgr.getDataStream();
796 if (pStrm)
797 pStrm->StopImport();
798 }
799 break;
800 case SID_DATA_PROVIDER:
801 {
802 auto xDoc = o3tl::make_shared<ScDocument>();
803 xDoc->InsertTab(0, "test");
805 ScDataProviderDlg aDialog(pTabViewShell->GetDialogParent(), xDoc, &rDoc);
806 if (aDialog.run() == RET_OK)
807 {
808 aDialog.import(rDoc);
809 }
810 }
811 break;
812 case SID_DATA_PROVIDER_REFRESH:
813 {
815 auto& rDataMapper = rDoc.GetExternalDataMapper();
816 for (auto& rDataSource : rDataMapper.getDataSources())
817 {
818 rDataSource.refresh(&rDoc, false);
819 }
820 }
821 break;
822 case SID_MANAGE_XML_SOURCE:
824 break;
825 case FID_VALIDATION:
826 case FID_CURRENTVALIDATION:
827 {
828 const SfxItemSet* pArgs = rReq.GetArgs();
829 if ( pArgs )
830 {
831 OSL_FAIL("later...");
832 }
833 else
834 {
838 OUString aExpr1, aExpr2;
839 bool bBlank = true;
840 sal_Int16 nListType = css::sheet::TableValidationVisibility::UNSORTED;
841 bool bShowHelp = false;
842 OUString aHelpTitle, aHelpText;
843 bool bShowError = false;
845 OUString aErrTitle, aErrText;
846
848 SCCOL nCurX = GetViewData().GetCurX();
849 SCROW nCurY = GetViewData().GetCurY();
850 SCTAB nTab = GetViewData().GetTabNo();
851 ScAddress aCursorPos( nCurX, nCurY, nTab );
852 sal_uInt32 nIndex = rDoc.GetAttr(
853 nCurX, nCurY, nTab, ATTR_VALIDDATA )->GetValue();
854 if ( nIndex )
855 {
856 const ScValidationData* pOldData = rDoc.GetValidationEntry( nIndex );
857 if ( pOldData )
858 {
859 eMode = pOldData->GetDataMode();
860 eOper = pOldData->GetOperation();
861 sal_uInt32 nNumFmt = 0;
862 if ( eMode == SC_VALID_DATE || eMode == SC_VALID_TIME )
863 {
864 SvNumFormatType nType = ( eMode == SC_VALID_DATE ) ? SvNumFormatType::DATE
865 : SvNumFormatType::TIME;
866 nNumFmt = rDoc.GetFormatTable()->GetStandardFormat(
868 }
869 aExpr1 = pOldData->GetExpression( aCursorPos, 0, nNumFmt );
870 aExpr2 = pOldData->GetExpression( aCursorPos, 1, nNumFmt );
871 bBlank = pOldData->IsIgnoreBlank();
872 nListType = pOldData->GetListType();
873
874 bShowHelp = pOldData->GetInput( aHelpTitle, aHelpText );
875 bShowError = pOldData->GetErrMsg( aErrTitle, aErrText, eErrStyle );
876
877 aArgSet.Put( SfxUInt16Item( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>(eMode) ) );
878 aArgSet.Put( SfxUInt16Item( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>(eOper) ) );
879 aArgSet.Put( SfxStringItem( FID_VALID_VALUE1, aExpr1 ) );
880 aArgSet.Put( SfxStringItem( FID_VALID_VALUE2, aExpr2 ) );
881 aArgSet.Put( SfxBoolItem( FID_VALID_BLANK, bBlank ) );
882 aArgSet.Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) );
883 aArgSet.Put( SfxBoolItem( FID_VALID_SHOWHELP, bShowHelp ) );
884 aArgSet.Put( SfxStringItem( FID_VALID_HELPTITLE, aHelpTitle ) );
885 aArgSet.Put( SfxStringItem( FID_VALID_HELPTEXT, aHelpText ) );
886 aArgSet.Put( SfxBoolItem( FID_VALID_SHOWERR, bShowError ) );
887 aArgSet.Put( SfxUInt16Item( FID_VALID_ERRSTYLE, sal::static_int_cast<sal_uInt16>(eErrStyle) ) );
888 aArgSet.Put( SfxStringItem( FID_VALID_ERRTITLE, aErrTitle ) );
889 aArgSet.Put( SfxStringItem( FID_VALID_ERRTEXT, aErrText ) );
890 }
891 }
892
893 // cell range picker
895 weld::Window* pParentWin = pWin ? pWin->GetFrameWeld() : nullptr;
896 auto xDlg = std::make_shared<ScValidationDlg>(pParentWin, &aArgSet, pTabViewShell);
897 ScValidationRegisteredDlg aRegisterThatDlgExists(pParentWin, xDlg);
898
899 short nResult = xDlg->run();
900 if ( nResult == RET_OK )
901 {
902 const SfxItemSet* pOutSet = xDlg->GetOutputItemSet();
903
904 if ( const SfxUInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_MODE ) )
905 eMode = static_cast<ScValidationMode>(pItem->GetValue());
906 if ( const SfxUInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_CONDMODE ) )
907 eOper = static_cast<ScConditionMode>(pItem->GetValue());
908 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_VALUE1 ) )
909 {
910 OUString aTemp1 = pItem->GetValue();
912 {
913 sal_uInt32 nNumIndex = 0;
914 double nVal;
915 if (rDoc.GetFormatTable()->IsNumberFormat(aTemp1, nNumIndex, nVal))
916 aExpr1 = ::rtl::math::doubleToUString( nVal,
917 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
919 else
920 aExpr1 = aTemp1;
921 }
922 else
923 aExpr1 = aTemp1;
924 }
925 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_VALUE2 ) )
926 {
927 OUString aTemp2 = pItem->GetValue();
929 {
930 sal_uInt32 nNumIndex = 0;
931 double nVal;
932 if (rDoc.GetFormatTable()->IsNumberFormat(aTemp2, nNumIndex, nVal))
933 aExpr2 = ::rtl::math::doubleToUString( nVal,
934 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
936 else
937 aExpr2 = aTemp2;
938 if ( eMode == SC_VALID_TIME ) {
939 sal_Int32 wraparound = aExpr1.compareTo(aExpr2);
940 if (wraparound > 0) {
941 if (eOper == ScConditionMode::Between) {
943 std::swap( aExpr1, aExpr2 );
944 }
945 else if (eOper == ScConditionMode::NotBetween) {
947 std::swap( aExpr1, aExpr2 );
948 }
949 }
950 }
951 }
952 else
953 aExpr2 = aTemp2;
954 }
955 if ( const SfxBoolItem* pItem = pOutSet->GetItemIfSet( FID_VALID_BLANK ) )
956 bBlank = pItem->GetValue();
957 if ( const SfxInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_LISTTYPE ) )
958 nListType = pItem->GetValue();
959
960 if ( const SfxBoolItem* pItem = pOutSet->GetItemIfSet( FID_VALID_SHOWHELP ) )
961 bShowHelp = pItem->GetValue();
962 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_HELPTITLE ) )
963 aHelpTitle = pItem->GetValue();
964 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_HELPTEXT ) )
965 aHelpText = pItem->GetValue();
966
967 if ( const SfxBoolItem* pItem = pOutSet->GetItemIfSet( FID_VALID_SHOWERR ) )
968 bShowError = pItem->GetValue();
969 if ( const SfxUInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_ERRSTYLE ) )
970 eErrStyle = static_cast<ScValidErrorStyle>(pItem->GetValue());
971 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_ERRTITLE ) )
972 aErrTitle = pItem->GetValue();
973 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_ERRTEXT ) )
974 aErrText = pItem->GetValue();
975
976 ScValidationData aData( eMode, eOper, aExpr1, aExpr2, rDoc, aCursorPos );
977 aData.SetIgnoreBlank( bBlank );
978 aData.SetListType( nListType );
979
980 aData.SetInput(aHelpTitle, aHelpText); // sets bShowInput to TRUE
981 if (!bShowHelp)
982 aData.ResetInput(); // reset only bShowInput
983
984 aData.SetError(aErrTitle, aErrText, eErrStyle); // sets bShowError to TRUE
985 if (!bShowError)
986 aData.ResetError(); // reset only bShowError
987
988 pTabViewShell->SetValidation( aData );
989 pTabViewShell->TestHintWindow();
990 rReq.Done( *pOutSet );
991 }
992 }
993 }
994 break;
995
996 case SID_TEXT_TO_COLUMNS:
997 {
998 ScViewData& rData = GetViewData();
999 ScRange aRange;
1000
1001 if ( lcl_GetTextToColumnsRange( rData, aRange, false ) )
1002 {
1003 ScDocument& rDoc = rData.GetDocument();
1004
1005 ScImportExport aExport( rDoc, aRange );
1007
1008 // #i87703# text to columns fails with tab separator
1009 aExport.SetDelimiter( u'\0' );
1010
1011 SvMemoryStream aStream;
1012 aStream.SetStreamCharSet( RTL_TEXTENCODING_UNICODE );
1014 aExport.ExportStream( aStream, OUString(), SotClipboardFormatId::STRING );
1015
1018 pTabViewShell->GetFrameWeld(), OUString(), &aStream, SC_TEXTTOCOLUMNS));
1019
1020 if ( pDlg->Execute() == RET_OK )
1021 {
1022 ScDocShell* pDocSh = rData.GetDocShell();
1023 OSL_ENSURE( pDocSh, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDocSh is null!" );
1024
1025 OUString aUndo = ScResId( STR_UNDO_TEXTTOCOLUMNS );
1026 pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, rData.GetViewShell()->GetViewShellId() );
1027
1028 ScImportExport aImport( rDoc, aRange.aStart );
1029 ScAsciiOptions aOptions;
1030 pDlg->GetOptions( aOptions );
1031 pDlg->SaveParameters();
1032 aImport.SetExtOptions( aOptions );
1033 aImport.SetApi( false );
1034 aImport.SetImportBroadcast( true );
1035 aImport.SetOverwriting( true );
1036 aStream.Seek( 0 );
1037 aImport.ImportStream( aStream, OUString(), SotClipboardFormatId::STRING );
1038
1039 pDocSh->GetUndoManager()->LeaveListAction();
1040 }
1041 }
1042 }
1043 break;
1044 }
1045}
1046
1048{
1049 ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
1050 ScViewData& rData = GetViewData();
1051 ScDocShell* pDocSh = rData.GetDocShell();
1052 ScDocument& rDoc = pDocSh->GetDocument();
1053 SCCOL nPosX = rData.GetCurX();
1054 SCROW nPosY = rData.GetCurY();
1055 SCTAB nTab = rData.GetTabNo();
1056
1057 bool bAutoFilter = false;
1058 bool bAutoFilterTested = false;
1059
1060 SfxWhichIter aIter(rSet);
1061 sal_uInt16 nWhich = aIter.FirstWhich();
1062 while (nWhich)
1063 {
1064 switch (nWhich)
1065 {
1066 case SID_REFRESH_DBAREA:
1067 {
1068 // imported data without selection
1069 // or filter,sort,subtotal (also without import)
1070 bool bOk = false;
1071 ScDBData* pDBData = pTabViewShell->GetDBData(false,SC_DB_OLD);
1072 if (pDBData && rDoc.GetChangeTrack() == nullptr)
1073 {
1074 if ( pDBData->HasImportParam() )
1075 bOk = !pDBData->HasImportSelection();
1076 else
1077 {
1078 bOk = pDBData->HasQueryParam() ||
1079 pDBData->HasSortParam() ||
1080 pDBData->HasSubTotalParam();
1081 }
1082 }
1083 if (!bOk)
1084 rSet.DisableItem( nWhich );
1085 }
1086 break;
1087
1088 case SID_FILTER:
1089 case SID_SPECIAL_FILTER:
1090 {
1091 ScRange aDummy;
1092 ScMarkType eMarkType = GetViewData().GetSimpleArea( aDummy);
1093 if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
1094 {
1095 rSet.DisableItem( nWhich );
1096 }
1097 }
1098 break;
1099
1100 //in case of Redlining and multiselection disable
1101 case SID_SORT_ASCENDING:
1102 case SID_SORT_DESCENDING:
1103 case SCITEM_SORTDATA:
1104 case SCITEM_SUBTDATA:
1105 case SID_OPENDLG_PIVOTTABLE:
1106 {
1108
1109 if ( pDocSh->IsReadOnly() || rDoc.GetChangeTrack()!=nullptr ||
1110 GetViewData().IsMultiMarked() )
1111 {
1112 rSet.DisableItem( nWhich );
1113 }
1114 }
1115 break;
1116
1117 case SID_REIMPORT_DATA:
1118 {
1119 // only imported data without selection
1120 ScDBData* pDBData = pTabViewShell->GetDBData(false,SC_DB_OLD);
1121 if (!pDBData || !pDBData->HasImportParam() || pDBData->HasImportSelection() ||
1122 rDoc.GetChangeTrack()!=nullptr)
1123 {
1124 rSet.DisableItem( nWhich );
1125 }
1126 }
1127 break;
1128
1129 case SID_VIEW_DATA_SOURCE_BROWSER:
1130 {
1131 if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::DATABASE))
1132 rSet.Put(SfxVisibilityItem(nWhich, false));
1133 else
1134 // get state (BoolItem) from SfxViewFrame
1135 pTabViewShell->GetViewFrame().GetSlotState( nWhich, nullptr, &rSet );
1136 }
1137 break;
1138 case SID_SBA_BRW_INSERT:
1139 {
1140 // SBA wants a sal_Bool-item, enabled
1141
1142 rSet.Put(SfxBoolItem(nWhich, true));
1143 }
1144 break;
1145
1146 case SID_AUTO_FILTER:
1147 case SID_AUTOFILTER_HIDE:
1148 {
1149 if (!bAutoFilterTested)
1150 {
1151 bAutoFilter = rDoc.HasAutoFilter( nPosX, nPosY, nTab );
1152 bAutoFilterTested = true;
1153 }
1154 if ( nWhich == SID_AUTO_FILTER )
1155 {
1156 ScRange aDummy;
1157 ScMarkType eMarkType = GetViewData().GetSimpleArea( aDummy);
1158 if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
1159 {
1160 rSet.DisableItem( nWhich );
1161 }
1162 else if (rDoc.GetDPAtBlock(aDummy))
1163 {
1164 rSet.DisableItem( nWhich );
1165 }
1166 else
1167 rSet.Put( SfxBoolItem( nWhich, bAutoFilter ) );
1168 }
1169 else
1170 if (!bAutoFilter)
1171 rSet.DisableItem( nWhich );
1172 }
1173 break;
1174
1175 case SID_UNFILTER:
1176 {
1177 SCCOL nStartCol, nEndCol;
1178 SCROW nStartRow, nEndRow;
1179 SCTAB nStartTab, nEndTab;
1180 bool bAnyQuery = false;
1181
1182 bool bSelected = (GetViewData().GetSimpleArea(
1183 nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab )
1184 == SC_MARK_SIMPLE);
1185
1186 if ( bSelected )
1187 {
1188 if (nStartCol==nEndCol && nStartRow==nEndRow)
1189 bSelected = false;
1190 }
1191 else
1192 {
1193 nStartCol = GetViewData().GetCurX();
1194 nStartRow = GetViewData().GetCurY();
1195 nStartTab = GetViewData().GetTabNo();
1196 }
1197
1198 ScDBData* pDBData = bSelected
1199 ? rDoc.GetDBAtArea( nStartTab, nStartCol, nStartRow, nEndCol, nEndRow )
1200 : rDoc.GetDBAtCursor( nStartCol, nStartRow, nStartTab, ScDBDataPortion::AREA );
1201
1202 if ( pDBData )
1203 {
1204 ScQueryParam aParam;
1205 pDBData->GetQueryParam( aParam );
1206 if ( aParam.GetEntry(0).bDoQuery )
1207 bAnyQuery = true;
1208 }
1209
1210 if ( !bAnyQuery )
1211 rSet.DisableItem( nWhich );
1212 }
1213 break;
1214
1215 case SID_DEFINE_DBNAME:
1216 {
1217 if ( pDocSh->IsDocShared() )
1218 {
1219 rSet.DisableItem( nWhich );
1220 }
1221 }
1222 break;
1223 case SID_DATA_PROVIDER:
1224 break;
1225 case SID_DATA_PROVIDER_REFRESH:
1226 {
1227 ScDocument& rViewDoc = GetViewData().GetDocument();
1228 auto& rDataMapper = rViewDoc.GetExternalDataMapper();
1229 if (rDataMapper.getDataSources().empty())
1230 rSet.DisableItem(nWhich);
1231 }
1232 break;
1233 case SID_DATA_STREAMS:
1234 case SID_DATA_STREAMS_PLAY:
1235 case SID_DATA_STREAMS_STOP:
1236 {
1237 if ( !officecfg::Office::Common::Misc::ExperimentalMode::get() )
1238 rSet.DisableItem( nWhich );
1239 }
1240 break;
1241 case SID_TEXT_TO_COLUMNS:
1242 {
1243 ScRange aRange;
1244 if ( !lcl_GetTextToColumnsRange( rData, aRange, true ) )
1245 {
1246 rSet.DisableItem( nWhich );
1247 }
1248 }
1249 break;
1250 case SID_MANAGE_XML_SOURCE:
1251 break;
1252 }
1253 nWhich = aIter.NextWhich();
1254 }
1255}
1256
1257/* 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:109
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:1047
void ExecuteDB(SfxRequest &rReq)
Definition: cellsh2.cxx:227
void ExecuteDataPilotDialog()
Definition: cellsh1.cxx:3167
void ExecuteSubtotals(SfxRequest &rReq)
Definition: cellsh1.cxx:3362
void ExecuteXMLSourceDialog()
Definition: cellsh1.cxx:3348
ScConditionMode GetOperation() const
Definition: conditio.hxx:368
bool IsIgnoreBlank() const
Definition: conditio.hxx:370
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:1250
Stores global named database ranges.
Definition: dbdata.hxx:243
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:324
void GetImportParam(ScImportParam &rImportParam) const
Definition: dbdata.cxx:483
SC_DLLPUBLIC bool HasQueryParam() const
Definition: dbdata.cxx:527
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:303
void SetImportParam(const ScImportParam &rImportParam)
Definition: dbdata.cxx:493
bool HasSubTotalParam() const
Definition: dbdata.cxx:545
SC_DLLPUBLIC void GetSortParam(ScSortParam &rSortParam) const
Definition: dbdata.cxx:404
bool HasSortParam() const
Definition: dbdata.cxx:538
SC_DLLPUBLIC void GetQueryParam(ScQueryParam &rQueryParam) const
Definition: dbdata.cxx:427
bool HasImportSelection() const
Definition: dbdata.hxx:209
bool HasImportParam() const
Definition: dbdata.cxx:522
void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dbdata.cxx:325
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:2115
bool ImportData(const ScImportParam &rParam)
Definition: dbfunc.cxx:451
void import(ScDocument &rDoc, bool bInternal=false)
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
void CancelAutoDBRange()
Definition: docsh5.cxx:368
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2963
void RefreshPivotTables(const ScRange &rSource)
Definition: docsh5.cxx:472
ScDPObject * GetDPAtBlock(const ScRange &rBlock) const
Definition: documen3.cxx:397
SC_DLLPUBLIC const ScValidationData * GetValidationEntry(sal_uInt32 nIndex) const
Definition: documen4.cxx:881
const ScDBData * GetDBAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab, ScDBDataPortion ePortion) const
Definition: documen3.cxx:328
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:344
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:1075
SC_DLLPUBLIC sc::ExternalDataMapper & GetExternalDataMapper()
SC_DLLPUBLIC bool HasColHeader(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab)
Definition: documen3.cxx:1540
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:5416
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:1100
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4789
bool HasAutoFilter(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: documen3.cxx:1508
SC_DLLPUBLIC SCSIZE GetEmptyLinesInBlock(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, ScDirection eDir)
Definition: document.cxx:6198
ScViewData & GetViewData()
Definition: formatsh.hxx:34
static SC_DLLPUBLIC LanguageType eLnge
Definition: global.hxx:559
static SC_DLLPUBLIC const LocaleDataWrapper & getLocaleData()
Definition: global.cxx:1053
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:433
bool ImportStream(SvStream &, const OUString &rBaseURL, SotClipboardFormatId)
Definition: impex.cxx:393
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:585
void SetExtOptions(const ScAsciiOptions &rOpt)
Definition: impex.cxx:205
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:1516
SC_DLLPUBLIC void InputEnterHandler(ScEnterMode nBlockMode=ScEnterMode::NORMAL, bool bBeforeSavingInLOK=false)
Definition: scmod.cxx:1408
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:674
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:2546
void TestHintWindow()
Definition: tabview3.cxx:780
void ErrorMessage(TranslateId pGlobStrId)
Definition: tabview2.cxx:1446
bool PaintExtras()
Definition: tabview3.cxx:2784
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1708
void ClearHighlightRanges()
Definition: tabview3.cxx:2556
void HideListBox()
Definition: tabview3.cxx:2993
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:3141
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:3157
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:1181
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:3461
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:342
@ DIR_LEFT
Definition: global.hxx:346
@ DIR_TOP
Definition: global.hxx:345
@ SC_DB_OLD
don't create
Definition: global.hxx:385
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:249
#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:48
bool mbCellFormats
If TRUE, consider the presence of cell formats.
Definition: sortparam.hxx:50
bool mbCellNotes
If TRUE, consider the presence of cell notes besides data.
Definition: sortparam.hxx:46
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:444
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:114
::std::vector< ScSortKeyState > maKeyState
Definition: sortparam.hxx:121
bool bHasHeader
Definition: sortparam.hxx:111
ScDataAreaExtras aDataAreaExtras
Definition: sortparam.hxx:109
sal_uInt16 nUserIndex
Definition: sortparam.hxx:110
sal_uInt16 GetSortKeyCount() const
Definition: sortparam.hxx:139
bool bCaseSens
Definition: sortparam.hxx:113
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