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* pViewFrame = pTabViewShell->GetViewFrame();
249 bool bWasOpen = false;
250 {
251 uno::Reference<frame::XFrame> xFrame = pViewFrame->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 pViewFrame->ExecuteSlot( rReq );
264 }
265 else
266 {
267 // show database beamer: SfxViewFrame call must be synchronous
268
269 pViewFrame->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* pViewFrm = pTabViewShell->GetViewFrame();
532 if (pViewFrm)
533 {
534 SfxRequest aRequest(pViewFrm, SID_SORT);
535
536 if ( rOutParam.bInplace )
537 {
538 aRequest.AppendItem( SfxBoolItem( SID_SORT_BYROW,
539 rOutParam.bByRow ) );
540 aRequest.AppendItem( SfxBoolItem( SID_SORT_HASHEADER,
541 rOutParam.bHasHeader ) );
542 aRequest.AppendItem( SfxBoolItem( SID_SORT_CASESENS,
543 rOutParam.bCaseSens ) );
544 aRequest.AppendItem( SfxBoolItem( SID_SORT_NATURALSORT,
545 rOutParam.bNaturalSort ) );
546 aRequest.AppendItem( SfxBoolItem( SID_SORT_INCCOMMENTS,
547 rOutParam.aDataAreaExtras.mbCellNotes ) );
548 aRequest.AppendItem( SfxBoolItem( SID_SORT_INCIMAGES,
550 aRequest.AppendItem( SfxBoolItem( SID_SORT_ATTRIBS,
551 rOutParam.aDataAreaExtras.mbCellFormats ) );
552 sal_uInt16 nUser = rOutParam.bUserDef ? ( rOutParam.nUserIndex + 1 ) : 0;
553 aRequest.AppendItem( SfxUInt16Item( SID_SORT_USERDEF, nUser ) );
554 if ( rOutParam.maKeyState[0].bDoSort )
555 {
556 aRequest.AppendItem( SfxInt32Item( FN_PARAM_1,
557 rOutParam.maKeyState[0].nField + 1 ) );
558 aRequest.AppendItem( SfxBoolItem( FN_PARAM_2,
559 rOutParam.maKeyState[0].bAscending ) );
560 }
561 if ( rOutParam.maKeyState[1].bDoSort )
562 {
563 aRequest.AppendItem( SfxInt32Item( FN_PARAM_3,
564 rOutParam.maKeyState[1].nField + 1 ) );
565 aRequest.AppendItem( SfxBoolItem( FN_PARAM_4,
566 rOutParam.maKeyState[1].bAscending ) );
567 }
568 if ( rOutParam.maKeyState[2].bDoSort )
569 {
570 aRequest.AppendItem( SfxInt32Item( FN_PARAM_5,
571 rOutParam.maKeyState[2].nField + 1 ) );
572 aRequest.AppendItem( SfxBoolItem( FN_PARAM_6,
573 rOutParam.maKeyState[2].bAscending ) );
574 }
575 }
576
577 aRequest.Done();
578 }
579 }
580 else
581 {
582 rData.GetDocShell()->CancelAutoDBRange();
583 }
584 };
585
586 pDlg->StartExecuteAsync(aContext);
587 }
588 }
589 }
590 break;
591
592 case SID_FILTER:
593 {
594 const SfxItemSet* pArgs = rReq.GetArgs();
595 if ( pArgs )
596 {
597 OSL_FAIL("SID_FILTER with arguments?");
598 pTabViewShell->Query(
599 pArgs->Get( SCITEM_QUERYDATA ).GetQueryData(), nullptr, true );
600 rReq.Done();
601 }
602 else
603 {
604 sal_uInt16 nId = ScFilterDlgWrapper::GetChildWindowId();
605 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
606 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
607
608 pScMod->SetRefDialog( nId, pWnd == nullptr );
609 }
610 }
611 break;
612
613 case SID_SPECIAL_FILTER:
614 {
615 const SfxItemSet* pArgs = rReq.GetArgs();
616 if ( pArgs )
617 {
618 OSL_FAIL("SID_SPECIAL_FILTER with arguments?");
619 pTabViewShell->Query(
620 pArgs->Get( SCITEM_QUERYDATA ).GetQueryData(), nullptr, true );
621 rReq.Done();
622 }
623 else
624 {
625 sal_uInt16 nId = ScSpecialFilterDlgWrapper::GetChildWindowId();
626 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
627 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
628
629 pScMod->SetRefDialog( nId, pWnd == nullptr );
630 }
631 }
632 break;
633
634 case FID_FILTER_OK:
635 {
636 const ScQueryItem* pQueryItem;
637 if ( pReqArgs && (pQueryItem =
638 pReqArgs->GetItemIfSet( SCITEM_QUERYDATA )) )
639 {
640 SCTAB nCurTab = GetViewData().GetTabNo();
641 SCTAB nRefTab = GetViewData().GetRefTabNo();
642
643 // If RefInput switched to a different sheet from the data sheet,
644 // switch back:
645
646 if ( nCurTab != nRefTab )
647 {
648 pTabViewShell->SetTabNo( nRefTab );
649 pTabViewShell->PaintExtras();
650 }
651
652 ScRange aAdvSource;
653 if (pQueryItem->GetAdvancedQuerySource(aAdvSource))
654 pTabViewShell->Query( pQueryItem->GetQueryData(), &aAdvSource, true );
655 else
656 pTabViewShell->Query( pQueryItem->GetQueryData(), nullptr, true );
657 rReq.Done( *pReqArgs );
658 }
659 }
660 break;
661
662 case SID_UNFILTER:
663 {
664 ScQueryParam aParam;
665 ScDBData* pDBData = pTabViewShell->GetDBData();
666
667 pDBData->GetQueryParam( aParam );
668 SCSIZE nEC = aParam.GetEntryCount();
669 for (SCSIZE i=0; i<nEC; i++)
670 aParam.GetEntry(i).bDoQuery = false;
671 aParam.bDuplicate = true;
672 pTabViewShell->Query( aParam, nullptr, true );
673 rReq.Done();
674 }
675 break;
676
677 case SID_AUTO_FILTER:
678 pTabViewShell->ToggleAutoFilter();
679 rReq.Done();
680 break;
681
682 case SID_AUTOFILTER_HIDE:
683 pTabViewShell->HideAutoFilter();
684 rReq.Done();
685 break;
686
687 case SID_PIVOT_TABLE:
688 {
689 const ScPivotItem* pPItem;
690 if ( pReqArgs && (pPItem =
691 pReqArgs->GetItemIfSet( SCITEM_PIVOTDATA )) )
692 {
693 SCTAB nCurTab = GetViewData().GetTabNo();
694 SCTAB nRefTab = GetViewData().GetRefTabNo();
695
696 // If RefInput switched to a different sheet from the data sheet,
697 // switch back:
698
699 if ( nCurTab != nRefTab )
700 {
701 pTabViewShell->SetTabNo( nRefTab );
702 pTabViewShell->PaintExtras();
703 }
704
705 const ScDPObject* pDPObject = pTabViewShell->GetDialogDPObject();
706 if ( pDPObject )
707 {
708 bool bSuccess = pTabViewShell->MakePivotTable(
709 pPItem->GetData(), pPItem->GetDestRange(), pPItem->IsNewSheet(), *pDPObject );
710 SfxBoolItem aRet(0, bSuccess);
711 rReq.SetReturnValue(aRet);
712 }
713 rReq.Done();
714 }
715#if HAVE_FEATURE_SCRIPTING
716 else if (rReq.IsAPI())
718#endif
719 }
720 break;
721
722 case SID_OPENDLG_PIVOTTABLE:
724 break;
725 case SID_DEFINE_DBNAME:
726 {
727
728 sal_uInt16 nId = ScDbNameDlgWrapper::GetChildWindowId();
729 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
730 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
731
732 pScMod->SetRefDialog( nId, pWnd == nullptr );
733
734 }
735 break;
736
737 case SID_SELECT_DB:
738 {
739 if ( pReqArgs )
740 {
741 const SfxStringItem& rItem
742 = static_cast<const SfxStringItem&>(pReqArgs->Get(SID_SELECT_DB));
743 pTabViewShell->GotoDBArea(rItem.GetValue());
744 rReq.Done();
745 }
746 else
747 {
749 ScDBCollection* pDBCol = rDoc.GetDBCollection();
750
751 if ( pDBCol )
752 {
753 std::vector<OUString> aList;
754 const ScDBCollection::NamedDBs& rDBs = pDBCol->getNamedDBs();
755 for (const auto& rxDB : rDBs)
756 aList.push_back(rxDB->GetName());
757
759
760 ScopedVclPtr<AbstractScSelEntryDlg> pDlg(pFact->CreateScSelEntryDlg(pTabViewShell->GetFrameWeld(), aList));
761 if ( pDlg->Execute() == RET_OK )
762 {
763 OUString aName = pDlg->GetSelectedEntry();
764 pTabViewShell->GotoDBArea( aName );
765 rReq.AppendItem( SfxStringItem( SID_SELECT_DB, aName ) );
766 rReq.Done();
767 }
768 }
769 }
770 }
771 break;
772 case SID_DATA_STREAMS:
773 {
774 sc::DataStreamDlg aDialog(GetViewData().GetDocShell(), pTabViewShell->GetFrameWeld());
777 sc::DataStream* pStrm = rMgr.getDataStream();
778 if (pStrm)
779 aDialog.Init(*pStrm);
780
781 if (aDialog.run() == RET_OK)
782 aDialog.StartStream();
783 }
784 break;
785 case SID_DATA_STREAMS_PLAY:
786 {
789 sc::DataStream* pStrm = rMgr.getDataStream();
790 if (pStrm)
791 pStrm->StartImport();
792 }
793 break;
794 case SID_DATA_STREAMS_STOP:
795 {
798 sc::DataStream* pStrm = rMgr.getDataStream();
799 if (pStrm)
800 pStrm->StopImport();
801 }
802 break;
803 case SID_DATA_PROVIDER:
804 {
805 auto xDoc = o3tl::make_shared<ScDocument>();
806 xDoc->InsertTab(0, "test");
808 ScDataProviderDlg aDialog(pTabViewShell->GetDialogParent(), xDoc, &rDoc);
809 if (aDialog.run() == RET_OK)
810 {
811 aDialog.import(rDoc);
812 }
813 }
814 break;
815 case SID_DATA_PROVIDER_REFRESH:
816 {
818 auto& rDataMapper = rDoc.GetExternalDataMapper();
819 for (auto& rDataSource : rDataMapper.getDataSources())
820 {
821 rDataSource.refresh(&rDoc, false);
822 }
823 }
824 break;
825 case SID_MANAGE_XML_SOURCE:
827 break;
828 case FID_VALIDATION:
829 case FID_CURRENTVALIDATION:
830 {
831 const SfxItemSet* pArgs = rReq.GetArgs();
832 if ( pArgs )
833 {
834 OSL_FAIL("later...");
835 }
836 else
837 {
841 OUString aExpr1, aExpr2;
842 bool bBlank = true;
843 sal_Int16 nListType = css::sheet::TableValidationVisibility::UNSORTED;
844 bool bShowHelp = false;
845 OUString aHelpTitle, aHelpText;
846 bool bShowError = false;
848 OUString aErrTitle, aErrText;
849
851 SCCOL nCurX = GetViewData().GetCurX();
852 SCROW nCurY = GetViewData().GetCurY();
853 SCTAB nTab = GetViewData().GetTabNo();
854 ScAddress aCursorPos( nCurX, nCurY, nTab );
855 sal_uInt32 nIndex = rDoc.GetAttr(
856 nCurX, nCurY, nTab, ATTR_VALIDDATA )->GetValue();
857 if ( nIndex )
858 {
859 const ScValidationData* pOldData = rDoc.GetValidationEntry( nIndex );
860 if ( pOldData )
861 {
862 eMode = pOldData->GetDataMode();
863 eOper = pOldData->GetOperation();
864 sal_uInt32 nNumFmt = 0;
865 if ( eMode == SC_VALID_DATE || eMode == SC_VALID_TIME )
866 {
867 SvNumFormatType nType = ( eMode == SC_VALID_DATE ) ? SvNumFormatType::DATE
868 : SvNumFormatType::TIME;
869 nNumFmt = rDoc.GetFormatTable()->GetStandardFormat(
871 }
872 aExpr1 = pOldData->GetExpression( aCursorPos, 0, nNumFmt );
873 aExpr2 = pOldData->GetExpression( aCursorPos, 1, nNumFmt );
874 bBlank = pOldData->IsIgnoreBlank();
875 nListType = pOldData->GetListType();
876
877 bShowHelp = pOldData->GetInput( aHelpTitle, aHelpText );
878 bShowError = pOldData->GetErrMsg( aErrTitle, aErrText, eErrStyle );
879
880 aArgSet.Put( SfxUInt16Item( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>(eMode) ) );
881 aArgSet.Put( SfxUInt16Item( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>(eOper) ) );
882 aArgSet.Put( SfxStringItem( FID_VALID_VALUE1, aExpr1 ) );
883 aArgSet.Put( SfxStringItem( FID_VALID_VALUE2, aExpr2 ) );
884 aArgSet.Put( SfxBoolItem( FID_VALID_BLANK, bBlank ) );
885 aArgSet.Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) );
886 aArgSet.Put( SfxBoolItem( FID_VALID_SHOWHELP, bShowHelp ) );
887 aArgSet.Put( SfxStringItem( FID_VALID_HELPTITLE, aHelpTitle ) );
888 aArgSet.Put( SfxStringItem( FID_VALID_HELPTEXT, aHelpText ) );
889 aArgSet.Put( SfxBoolItem( FID_VALID_SHOWERR, bShowError ) );
890 aArgSet.Put( SfxUInt16Item( FID_VALID_ERRSTYLE, sal::static_int_cast<sal_uInt16>(eErrStyle) ) );
891 aArgSet.Put( SfxStringItem( FID_VALID_ERRTITLE, aErrTitle ) );
892 aArgSet.Put( SfxStringItem( FID_VALID_ERRTEXT, aErrText ) );
893 }
894 }
895
896 // cell range picker
898 weld::Window* pParentWin = pWin ? pWin->GetFrameWeld() : nullptr;
899 auto xDlg = std::make_shared<ScValidationDlg>(pParentWin, &aArgSet, pTabViewShell);
900 ScValidationRegisteredDlg aRegisterThatDlgExists(pParentWin, xDlg);
901
902 short nResult = xDlg->run();
903 if ( nResult == RET_OK )
904 {
905 const SfxItemSet* pOutSet = xDlg->GetOutputItemSet();
906
907 if ( const SfxUInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_MODE ) )
908 eMode = static_cast<ScValidationMode>(pItem->GetValue());
909 if ( const SfxUInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_CONDMODE ) )
910 eOper = static_cast<ScConditionMode>(pItem->GetValue());
911 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_VALUE1 ) )
912 {
913 OUString aTemp1 = pItem->GetValue();
915 {
916 sal_uInt32 nNumIndex = 0;
917 double nVal;
918 if (rDoc.GetFormatTable()->IsNumberFormat(aTemp1, nNumIndex, nVal))
919 aExpr1 = ::rtl::math::doubleToUString( nVal,
920 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
922 else
923 aExpr1 = aTemp1;
924 }
925 else
926 aExpr1 = aTemp1;
927 }
928 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_VALUE2 ) )
929 {
930 OUString aTemp2 = pItem->GetValue();
932 {
933 sal_uInt32 nNumIndex = 0;
934 double nVal;
935 if (rDoc.GetFormatTable()->IsNumberFormat(aTemp2, nNumIndex, nVal))
936 aExpr2 = ::rtl::math::doubleToUString( nVal,
937 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
939 else
940 aExpr2 = aTemp2;
941 if ( eMode == SC_VALID_TIME ) {
942 sal_Int32 wraparound = aExpr1.compareTo(aExpr2);
943 if (wraparound > 0) {
944 if (eOper == ScConditionMode::Between) {
946 std::swap( aExpr1, aExpr2 );
947 }
948 else if (eOper == ScConditionMode::NotBetween) {
950 std::swap( aExpr1, aExpr2 );
951 }
952 }
953 }
954 }
955 else
956 aExpr2 = aTemp2;
957 }
958 if ( const SfxBoolItem* pItem = pOutSet->GetItemIfSet( FID_VALID_BLANK ) )
959 bBlank = pItem->GetValue();
960 if ( const SfxInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_LISTTYPE ) )
961 nListType = pItem->GetValue();
962
963 if ( const SfxBoolItem* pItem = pOutSet->GetItemIfSet( FID_VALID_SHOWHELP ) )
964 bShowHelp = pItem->GetValue();
965 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_HELPTITLE ) )
966 aHelpTitle = pItem->GetValue();
967 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_HELPTEXT ) )
968 aHelpText = pItem->GetValue();
969
970 if ( const SfxBoolItem* pItem = pOutSet->GetItemIfSet( FID_VALID_SHOWERR ) )
971 bShowError = pItem->GetValue();
972 if ( const SfxUInt16Item* pItem = pOutSet->GetItemIfSet( FID_VALID_ERRSTYLE ) )
973 eErrStyle = static_cast<ScValidErrorStyle>(pItem->GetValue());
974 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_ERRTITLE ) )
975 aErrTitle = pItem->GetValue();
976 if ( const SfxStringItem* pItem = pOutSet->GetItemIfSet( FID_VALID_ERRTEXT ) )
977 aErrText = pItem->GetValue();
978
979 ScValidationData aData( eMode, eOper, aExpr1, aExpr2, rDoc, aCursorPos );
980 aData.SetIgnoreBlank( bBlank );
981 aData.SetListType( nListType );
982
983 aData.SetInput(aHelpTitle, aHelpText); // sets bShowInput to TRUE
984 if (!bShowHelp)
985 aData.ResetInput(); // reset only bShowInput
986
987 aData.SetError(aErrTitle, aErrText, eErrStyle); // sets bShowError to TRUE
988 if (!bShowError)
989 aData.ResetError(); // reset only bShowError
990
991 pTabViewShell->SetValidation( aData );
992 pTabViewShell->TestHintWindow();
993 rReq.Done( *pOutSet );
994 }
995 }
996 }
997 break;
998
999 case SID_TEXT_TO_COLUMNS:
1000 {
1001 ScViewData& rData = GetViewData();
1002 ScRange aRange;
1003
1004 if ( lcl_GetTextToColumnsRange( rData, aRange, false ) )
1005 {
1006 ScDocument& rDoc = rData.GetDocument();
1007
1008 ScImportExport aExport( rDoc, aRange );
1010
1011 // #i87703# text to columns fails with tab separator
1012 aExport.SetDelimiter( u'\0' );
1013
1014 SvMemoryStream aStream;
1015 aStream.SetStreamCharSet( RTL_TEXTENCODING_UNICODE );
1017 aExport.ExportStream( aStream, OUString(), SotClipboardFormatId::STRING );
1018
1021 pTabViewShell->GetFrameWeld(), OUString(), &aStream, SC_TEXTTOCOLUMNS));
1022
1023 if ( pDlg->Execute() == RET_OK )
1024 {
1025 ScDocShell* pDocSh = rData.GetDocShell();
1026 OSL_ENSURE( pDocSh, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDocSh is null!" );
1027
1028 OUString aUndo = ScResId( STR_UNDO_TEXTTOCOLUMNS );
1029 pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, rData.GetViewShell()->GetViewShellId() );
1030
1031 ScImportExport aImport( rDoc, aRange.aStart );
1032 ScAsciiOptions aOptions;
1033 pDlg->GetOptions( aOptions );
1034 pDlg->SaveParameters();
1035 aImport.SetExtOptions( aOptions );
1036 aImport.SetApi( false );
1037 aImport.SetImportBroadcast( true );
1038 aImport.SetOverwriting( true );
1039 aStream.Seek( 0 );
1040 aImport.ImportStream( aStream, OUString(), SotClipboardFormatId::STRING );
1041
1042 pDocSh->GetUndoManager()->LeaveListAction();
1043 }
1044 }
1045 }
1046 break;
1047 }
1048}
1049
1051{
1052 ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
1053 ScViewData& rData = GetViewData();
1054 ScDocShell* pDocSh = rData.GetDocShell();
1055 ScDocument& rDoc = pDocSh->GetDocument();
1056 SCCOL nPosX = rData.GetCurX();
1057 SCROW nPosY = rData.GetCurY();
1058 SCTAB nTab = rData.GetTabNo();
1059
1060 bool bAutoFilter = false;
1061 bool bAutoFilterTested = false;
1062
1063 SfxWhichIter aIter(rSet);
1064 sal_uInt16 nWhich = aIter.FirstWhich();
1065 while (nWhich)
1066 {
1067 switch (nWhich)
1068 {
1069 case SID_REFRESH_DBAREA:
1070 {
1071 // imported data without selection
1072 // or filter,sort,subtotal (also without import)
1073 bool bOk = false;
1074 ScDBData* pDBData = pTabViewShell->GetDBData(false,SC_DB_OLD);
1075 if (pDBData && rDoc.GetChangeTrack() == nullptr)
1076 {
1077 if ( pDBData->HasImportParam() )
1078 bOk = !pDBData->HasImportSelection();
1079 else
1080 {
1081 bOk = pDBData->HasQueryParam() ||
1082 pDBData->HasSortParam() ||
1083 pDBData->HasSubTotalParam();
1084 }
1085 }
1086 if (!bOk)
1087 rSet.DisableItem( nWhich );
1088 }
1089 break;
1090
1091 case SID_FILTER:
1092 case SID_SPECIAL_FILTER:
1093 {
1094 ScRange aDummy;
1095 ScMarkType eMarkType = GetViewData().GetSimpleArea( aDummy);
1096 if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
1097 {
1098 rSet.DisableItem( nWhich );
1099 }
1100 }
1101 break;
1102
1103 //in case of Redlining and multiselection disable
1104 case SID_SORT_ASCENDING:
1105 case SID_SORT_DESCENDING:
1106 case SCITEM_SORTDATA:
1107 case SCITEM_SUBTDATA:
1108 case SID_OPENDLG_PIVOTTABLE:
1109 {
1111
1112 if ( pDocSh->IsReadOnly() || rDoc.GetChangeTrack()!=nullptr ||
1113 GetViewData().IsMultiMarked() )
1114 {
1115 rSet.DisableItem( nWhich );
1116 }
1117 }
1118 break;
1119
1120 case SID_REIMPORT_DATA:
1121 {
1122 // only imported data without selection
1123 ScDBData* pDBData = pTabViewShell->GetDBData(false,SC_DB_OLD);
1124 if (!pDBData || !pDBData->HasImportParam() || pDBData->HasImportSelection() ||
1125 rDoc.GetChangeTrack()!=nullptr)
1126 {
1127 rSet.DisableItem( nWhich );
1128 }
1129 }
1130 break;
1131
1132 case SID_VIEW_DATA_SOURCE_BROWSER:
1133 {
1134 if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::DATABASE))
1135 rSet.Put(SfxVisibilityItem(nWhich, false));
1136 else
1137 // get state (BoolItem) from SfxViewFrame
1138 pTabViewShell->GetViewFrame()->GetSlotState( nWhich, nullptr, &rSet );
1139 }
1140 break;
1141 case SID_SBA_BRW_INSERT:
1142 {
1143 // SBA wants a sal_Bool-item, enabled
1144
1145 rSet.Put(SfxBoolItem(nWhich, true));
1146 }
1147 break;
1148
1149 case SID_AUTO_FILTER:
1150 case SID_AUTOFILTER_HIDE:
1151 {
1152 if (!bAutoFilterTested)
1153 {
1154 bAutoFilter = rDoc.HasAutoFilter( nPosX, nPosY, nTab );
1155 bAutoFilterTested = true;
1156 }
1157 if ( nWhich == SID_AUTO_FILTER )
1158 {
1159 ScRange aDummy;
1160 ScMarkType eMarkType = GetViewData().GetSimpleArea( aDummy);
1161 if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
1162 {
1163 rSet.DisableItem( nWhich );
1164 }
1165 else if (rDoc.GetDPAtBlock(aDummy))
1166 {
1167 rSet.DisableItem( nWhich );
1168 }
1169 else
1170 rSet.Put( SfxBoolItem( nWhich, bAutoFilter ) );
1171 }
1172 else
1173 if (!bAutoFilter)
1174 rSet.DisableItem( nWhich );
1175 }
1176 break;
1177
1178 case SID_UNFILTER:
1179 {
1180 SCCOL nStartCol, nEndCol;
1181 SCROW nStartRow, nEndRow;
1182 SCTAB nStartTab, nEndTab;
1183 bool bAnyQuery = false;
1184
1185 bool bSelected = (GetViewData().GetSimpleArea(
1186 nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab )
1187 == SC_MARK_SIMPLE);
1188
1189 if ( bSelected )
1190 {
1191 if (nStartCol==nEndCol && nStartRow==nEndRow)
1192 bSelected = false;
1193 }
1194 else
1195 {
1196 nStartCol = GetViewData().GetCurX();
1197 nStartRow = GetViewData().GetCurY();
1198 nStartTab = GetViewData().GetTabNo();
1199 }
1200
1201 ScDBData* pDBData = bSelected
1202 ? rDoc.GetDBAtArea( nStartTab, nStartCol, nStartRow, nEndCol, nEndRow )
1203 : rDoc.GetDBAtCursor( nStartCol, nStartRow, nStartTab, ScDBDataPortion::AREA );
1204
1205 if ( pDBData )
1206 {
1207 ScQueryParam aParam;
1208 pDBData->GetQueryParam( aParam );
1209 if ( aParam.GetEntry(0).bDoQuery )
1210 bAnyQuery = true;
1211 }
1212
1213 if ( !bAnyQuery )
1214 rSet.DisableItem( nWhich );
1215 }
1216 break;
1217
1218 case SID_DEFINE_DBNAME:
1219 {
1220 if ( pDocSh->IsDocShared() )
1221 {
1222 rSet.DisableItem( nWhich );
1223 }
1224 }
1225 break;
1226 case SID_DATA_PROVIDER:
1227 break;
1228 case SID_DATA_PROVIDER_REFRESH:
1229 {
1230 ScDocument& rViewDoc = GetViewData().GetDocument();
1231 auto& rDataMapper = rViewDoc.GetExternalDataMapper();
1232 if (rDataMapper.getDataSources().empty())
1233 rSet.DisableItem(nWhich);
1234 }
1235 break;
1236 case SID_DATA_STREAMS:
1237 case SID_DATA_STREAMS_PLAY:
1238 case SID_DATA_STREAMS_STOP:
1239 {
1240 if ( !officecfg::Office::Common::Misc::ExperimentalMode::get() )
1241 rSet.DisableItem( nWhich );
1242 }
1243 break;
1244 case SID_TEXT_TO_COLUMNS:
1245 {
1246 ScRange aRange;
1247 if ( !lcl_GetTextToColumnsRange( rData, aRange, true ) )
1248 {
1249 rSet.DisableItem( nWhich );
1250 }
1251 }
1252 break;
1253 case SID_MANAGE_XML_SOURCE:
1254 break;
1255 }
1256 nWhich = aIter.NextWhich();
1257 }
1258}
1259
1260/* 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:106
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:1050
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:235
NamedDBs & getNamedDBs()
Definition: dbdata.hxx:316
void GetImportParam(ScImportParam &rImportParam) const
Definition: dbdata.cxx:480
SC_DLLPUBLIC bool HasQueryParam() const
Definition: dbdata.cxx:524
void GetArea(SCTAB &rTab, SCCOL &rCol1, SCROW &rRow1, SCCOL &rCol2, SCROW &rRow2) const
Definition: dbdata.cxx:300
void SetImportParam(const ScImportParam &rImportParam)
Definition: dbdata.cxx:490
bool HasSubTotalParam() const
Definition: dbdata.cxx:542
SC_DLLPUBLIC void GetSortParam(ScSortParam &rSortParam) const
Definition: dbdata.cxx:401
bool HasSortParam() const
Definition: dbdata.cxx:535
SC_DLLPUBLIC void GetQueryParam(ScQueryParam &rQueryParam) const
Definition: dbdata.cxx:424
bool HasImportSelection() const
Definition: dbdata.hxx:201
bool HasImportParam() const
Definition: dbdata.cxx:519
void SetArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
Definition: dbdata.cxx:322
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:2945
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:892
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:826
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
sc::DocumentLinkManager & GetDocLinkManager()
Definition: documen2.cxx:241
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2487
bool IsBlockEmpty(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab) const
Definition: document.cxx:5405
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:4778
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:6187
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:157
void SetExportTextOptions(const ScExportTextOptions &options)
Definition: impex.hxx:160
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:158
void SetOverwriting(const bool bOverwriting)
Definition: impex.hxx:159
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:133
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:666
const ScDPObject * GetDialogDPObject() const
Definition: tabvwsh.hxx:288
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:783
void ErrorMessage(TranslateId pGlobStrId)
Definition: tabview2.cxx:1446
bool PaintExtras()
Definition: tabview3.cxx:2787
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1711
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:1822
ScValidationMode GetDataMode() const
Definition: validat.hxx:114
sal_Int16 GetListType() const
Definition: validat.hxx:116
bool GetInput(OUString &rTitle, OUString &rMsg) const
Definition: validat.hxx:108
bool GetErrMsg(OUString &rTitle, OUString &rMsg, ScValidErrorStyle &rStyle) const
Definition: validat.cxx:176
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:377
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:39
@ SC_VALID_TIME
Definition: validat.hxx:44
@ SC_VALID_ANY
Definition: validat.hxx:40
@ SC_VALID_DATE
Definition: validat.hxx:43
ScValidErrorStyle
Definition: validat.hxx:51
@ SC_VALERR_STOP
Definition: validat.hxx:52
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