GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / sc / source / ui / view / cellsh2.cxx
blob71c92825ca1adea5804ccd82acf48fdcbf8d91bc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "scitems.hxx"
21 #include <sfx2/viewfrm.hxx>
22 #include <sfx2/app.hxx>
23 #include <sfx2/linkmgr.hxx>
24 #include <sfx2/request.hxx>
25 #include <svl/aeitem.hxx>
26 #include <basic/sbxcore.hxx>
27 #include <svl/whiter.hxx>
28 #include <svl/zforlist.hxx>
29 #include <vcl/msgbox.hxx>
30 #include <svl/stritem.hxx>
31 #include <svl/visitem.hxx>
32 #include <svtools/miscopt.hxx>
33 #include <unotools/moduleoptions.hxx>
35 #include <com/sun/star/frame/FrameSearchFlag.hpp>
36 #include <com/sun/star/sdbc/XResultSet.hpp>
38 #include "cellsh.hxx"
39 #include "tabvwsh.hxx"
40 #include "sc.hrc"
41 #include "globstr.hrc"
42 #include "global.hxx"
43 #include "globalnames.hxx"
44 #include "scmod.hxx"
45 #include "docsh.hxx"
46 #include "document.hxx"
47 #include "uiitems.hxx"
48 #include "dbfunc.hxx"
49 #include "dbdocfun.hxx"
50 #include "filtdlg.hxx"
51 #include "dbnamdlg.hxx"
52 #include "reffact.hxx"
53 #include "validat.hxx"
54 #include "scresid.hxx"
56 #include "validate.hrc"
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 "queryentry.hxx"
64 #include "markdata.hxx"
66 #include <config_orcus.h>
68 using namespace com::sun::star;
70 static bool lcl_GetTextToColumnsRange( const ScViewData* pData, ScRange& rRange )
72 OSL_ENSURE( pData, "lcl_GetTextToColumnsRange: pData is null!" );
74 bool bRet = false;
75 const ScMarkData& rMark = pData->GetMarkData();
77 if ( rMark.IsMarked() )
79 if ( !rMark.IsMultiMarked() )
81 rMark.GetMarkArea( rRange );
82 if ( rRange.aStart.Col() == rRange.aEnd.Col() )
84 bRet = true;
88 else
90 const SCCOL nCol = pData->GetCurX();
91 const SCROW nRow = pData->GetCurY();
92 const SCTAB nTab = pData->GetTabNo();
93 rRange = ScRange( nCol, nRow, nTab, nCol, nRow, nTab );
94 bRet = true;
97 const ScDocument* pDoc = pData->GetDocument();
98 OSL_ENSURE( pDoc, "lcl_GetTextToColumnsRange: pDoc is null!" );
100 if ( bRet && pDoc->IsBlockEmpty( rRange.aStart.Tab(), rRange.aStart.Col(),
101 rRange.aStart.Row(), rRange.aEnd.Col(),
102 rRange.aEnd.Row() ) )
104 bRet = false;
107 return bRet;
110 static sal_Bool lcl_GetSortParam( const ScViewData* pData, ScSortParam& rSortParam )
112 ScTabViewShell* pTabViewShell = pData->GetViewShell();
113 ScDBData* pDBData = pTabViewShell->GetDBData();
114 ScDocument* pDoc = pData->GetDocument();
115 SCTAB nTab = pData->GetTabNo();
116 ScDirection eFillDir = DIR_TOP;
117 sal_Bool bSort = sal_True;
118 ScRange aExternalRange;
120 if( rSortParam.nCol1 != rSortParam.nCol2 )
121 eFillDir = DIR_LEFT;
122 if( rSortParam.nRow1 != rSortParam.nRow2 )
123 eFillDir = DIR_TOP;
125 SCSIZE nCount = pDoc->GetEmptyLinesInBlock( rSortParam.nCol1, rSortParam.nRow1, nTab, rSortParam.nCol2, rSortParam.nRow2, nTab, eFillDir );
127 if( rSortParam.nRow2 == MAXROW )
128 aExternalRange = ScRange( rSortParam.nCol1,sal::static_int_cast<SCROW>( nCount ), nTab );
129 else
130 aExternalRange = ScRange( pData->GetCurX(), pData->GetCurY(), nTab );
132 SCROW nStartRow = aExternalRange.aStart.Row();
133 SCCOL nStartCol = aExternalRange.aStart.Col();
134 SCROW nEndRow = aExternalRange.aEnd.Row();
135 SCCOL nEndCol = aExternalRange.aEnd.Col();
136 pDoc->GetDataArea( aExternalRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow, false, false );
137 aExternalRange.aStart.SetRow( nStartRow );
138 aExternalRange.aStart.SetCol( nStartCol );
139 aExternalRange.aEnd.SetRow( nEndRow );
140 aExternalRange.aEnd.SetCol( nEndCol );
142 if(( rSortParam.nCol1 == rSortParam.nCol2 && aExternalRange.aStart.Col() != aExternalRange.aEnd.Col() ) ||
143 ( rSortParam.nRow1 == rSortParam.nRow2 && aExternalRange.aStart.Row() != aExternalRange.aEnd.Row() ) )
145 sal_uInt16 nFmt = SCA_VALID;
147 pTabViewShell->AddHighlightRange( aExternalRange,Color( COL_LIGHTBLUE ) );
148 ScRange rExtendRange( aExternalRange.aStart.Col(), aExternalRange.aStart.Row(), nTab, aExternalRange.aEnd.Col(), aExternalRange.aEnd.Row(), nTab );
149 OUString aExtendStr(rExtendRange.Format(nFmt, pDoc));
151 ScRange rCurrentRange( rSortParam.nCol1, rSortParam.nRow1, nTab, rSortParam.nCol2, rSortParam.nRow2, nTab );
152 OUString aCurrentStr(rCurrentRange.Format(nFmt, pDoc));
154 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
155 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
157 AbstractScSortWarningDlg* pWarningDlg = pFact->CreateScSortWarningDlg( pTabViewShell->GetDialogParent(), aExtendStr, aCurrentStr );
158 OSL_ENSURE(pWarningDlg, "Dialog create fail!");
159 short bResult = pWarningDlg->Execute();
160 if( bResult == BTN_EXTEND_RANGE || bResult == BTN_CURRENT_SELECTION )
162 if( bResult == BTN_EXTEND_RANGE )
164 pTabViewShell->MarkRange( aExternalRange, false );
165 pDBData->SetArea( nTab, aExternalRange.aStart.Col(), aExternalRange.aStart.Row(), aExternalRange.aEnd.Col(), aExternalRange.aEnd.Row() );
168 else
170 bSort = false;
171 pData->GetDocShell()->CancelAutoDBRange();
174 delete pWarningDlg;
175 pTabViewShell->ClearHighlightRanges();
177 return bSort;
180 //after end execute from !IsModalInputMode, it is safer to delay deleting
181 namespace
183 long DelayDeleteAbstractDialog( void *pAbstractDialog, void * /*pArg*/ )
185 delete reinterpret_cast<SfxAbstractTabDialog*>( pAbstractDialog );
186 return 0;
190 void ScCellShell::ExecuteDB( SfxRequest& rReq )
192 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
193 sal_uInt16 nSlotId = rReq.GetSlot();
194 const SfxItemSet* pReqArgs = rReq.GetArgs();
195 ScModule* pScMod = SC_MOD();
197 pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
199 if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
201 pScMod->InputEnterHandler();
202 pTabViewShell->UpdateInputHandler();
205 switch ( nSlotId )
207 case SID_VIEW_DATA_SOURCE_BROWSER:
209 // check if database beamer is open
211 SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
212 sal_Bool bWasOpen = false;
214 uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame().GetFrameInterface();
215 uno::Reference<frame::XFrame> xBeamerFrame = xFrame->findFrame(
216 OUString("_beamer"),
217 frame::FrameSearchFlag::CHILDREN);
218 if ( xBeamerFrame.is() )
219 bWasOpen = sal_True;
222 if ( bWasOpen )
224 // close database beamer: just forward to SfxViewFrame
226 pViewFrame->ExecuteSlot( rReq );
228 else
230 // show database beamer: SfxViewFrame call must be synchronous
232 pViewFrame->ExecuteSlot( rReq, (sal_Bool) false ); // sal_False = synchronous
234 // select current database in database beamer
236 ScImportParam aImportParam;
237 ScDBData* pDBData = pTabViewShell->GetDBData(sal_True,SC_DB_OLD); // don't create if none found
238 if (pDBData)
239 pDBData->GetImportParam( aImportParam );
241 ScDBDocFunc::ShowInBeamer( aImportParam, pTabViewShell->GetViewFrame() );
243 rReq.Done(); // needed because it's a toggle slot
245 break;
247 case SID_REIMPORT_DATA:
249 sal_Bool bOk = false;
250 ScDBData* pDBData = pTabViewShell->GetDBData(sal_True,SC_DB_OLD);
251 if (pDBData)
253 ScImportParam aImportParam;
254 pDBData->GetImportParam( aImportParam );
255 if (aImportParam.bImport && !pDBData->HasImportSelection())
257 pTabViewShell->ImportData( aImportParam );
258 pDBData->SetImportParam( aImportParam ); //! Undo ??
259 bOk = sal_True;
263 if (!bOk && ! rReq.IsAPI() )
264 pTabViewShell->ErrorMessage(STR_REIMPORT_EMPTY);
266 if( bOk )
267 rReq.Done();
269 break;
271 case SID_REFRESH_DBAREA:
273 ScDBData* pDBData = pTabViewShell->GetDBData(sal_True,SC_DB_OLD);
274 if (pDBData)
276 // repeat import like SID_REIMPORT_DATA
278 sal_Bool bContinue = sal_True;
279 ScImportParam aImportParam;
280 pDBData->GetImportParam( aImportParam );
281 if (aImportParam.bImport && !pDBData->HasImportSelection())
283 bContinue = pTabViewShell->ImportData( aImportParam );
284 pDBData->SetImportParam( aImportParam ); //! Undo ??
286 // mark (size may have been changed)
287 ScRange aNewRange;
288 pDBData->GetArea(aNewRange);
289 pTabViewShell->MarkRange(aNewRange);
292 if ( bContinue ) // fail at import -> break
294 // internal operations, when any stored
296 if ( pDBData->HasQueryParam() || pDBData->HasSortParam() ||
297 pDBData->HasSubTotalParam() )
298 pTabViewShell->RepeatDB();
300 // pivot tables that have the range as data source
302 ScRange aRange;
303 pDBData->GetArea(aRange);
304 GetViewData()->GetDocShell()->RefreshPivotTables(aRange);
307 rReq.Done();
309 break;
311 case SID_SBA_BRW_INSERT:
313 OSL_FAIL( "Deprecated Slot" );
315 break;
317 case SID_DATA_FORM:
319 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
320 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
322 AbstractScDataFormDlg* pDlg = pFact->CreateScDataFormDlg(
323 pTabViewShell->GetDialogParent(), pTabViewShell);
324 OSL_ENSURE(pDlg, "Dialog create fail!");
326 pDlg->Execute();
328 rReq.Done();
330 break;
332 case SID_SUBTOTALS:
333 ExecuteSubtotals(rReq);
334 break;
336 case SID_SORT_DESCENDING:
337 case SID_SORT_ASCENDING:
339 //#i60401 ux-ctest: Calc does not support all users' strategies regarding sorting data
340 //the patch comes from maoyg
341 ScSortParam aSortParam;
342 ScDBData* pDBData = pTabViewShell->GetDBData();
343 ScViewData* pData = GetViewData();
345 pDBData->GetSortParam( aSortParam );
347 if( lcl_GetSortParam( pData, aSortParam ) )
349 SfxItemSet aArgSet( GetPool(), SCITEM_SORTDATA, SCITEM_SORTDATA );
350 SCCOL nCol = GetViewData()->GetCurX();
351 SCCOL nTab = GetViewData()->GetTabNo();
352 ScDocument* pDoc = GetViewData()->GetDocument();
354 pDBData->GetSortParam( aSortParam );
355 sal_Bool bHasHeader = pDoc->HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, nTab );
357 if( nCol < aSortParam.nCol1 )
358 nCol = aSortParam.nCol1;
359 else if( nCol > aSortParam.nCol2 )
360 nCol = aSortParam.nCol2;
362 aSortParam.bHasHeader = bHasHeader;
363 aSortParam.bByRow = true;
364 aSortParam.bCaseSens = false;
365 aSortParam.bNaturalSort = false;
366 aSortParam.bIncludePattern = true;
367 aSortParam.bInplace = true;
368 aSortParam.maKeyState[0].bDoSort = true;
369 aSortParam.maKeyState[0].nField = nCol;
370 aSortParam.maKeyState[0].bAscending = ( nSlotId == SID_SORT_ASCENDING );
372 for ( sal_uInt16 i=1; i<aSortParam.GetSortKeyCount(); i++ )
373 aSortParam.maKeyState[i].bDoSort = false;
375 aArgSet.Put( ScSortItem( SCITEM_SORTDATA, GetViewData(), &aSortParam ) );
377 pTabViewShell->UISort( aSortParam ); // subtotal when needed new
379 rReq.Done();
382 break;
384 case SID_SORT:
386 const SfxItemSet* pArgs = rReq.GetArgs();
388 //#i60401 ux-ctest: Calc does not support all users' strategies regarding sorting data
389 //the patch comes from maoyg
391 if ( pArgs ) // Basic
393 ScSortParam aSortParam;
394 ScDBData* pDBData = pTabViewShell->GetDBData();
395 ScViewData* pData = GetViewData();
397 pDBData->GetSortParam( aSortParam );
399 if( lcl_GetSortParam( pData, aSortParam ) )
401 ScDocument* pDoc = GetViewData()->GetDocument();
403 pDBData->GetSortParam( aSortParam );
404 sal_Bool bHasHeader = pDoc->HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, pData->GetTabNo() );
405 if( bHasHeader )
406 aSortParam.bHasHeader = bHasHeader;
408 aSortParam.bInplace = sal_True; // from Basic always
410 const SfxPoolItem* pItem;
411 if ( pArgs->GetItemState( SID_SORT_BYROW, sal_True, &pItem ) == SFX_ITEM_SET )
412 aSortParam.bByRow = static_cast<const SfxBoolItem*>(pItem)->GetValue();
413 if ( pArgs->GetItemState( SID_SORT_HASHEADER, sal_True, &pItem ) == SFX_ITEM_SET )
414 aSortParam.bHasHeader = static_cast<const SfxBoolItem*>(pItem)->GetValue();
415 if ( pArgs->GetItemState( SID_SORT_CASESENS, sal_True, &pItem ) == SFX_ITEM_SET )
416 aSortParam.bCaseSens = static_cast<const SfxBoolItem*>(pItem)->GetValue();
417 if ( pArgs->GetItemState( SID_SORT_NATURALSORT, true, &pItem ) == SFX_ITEM_SET )
418 aSortParam.bNaturalSort = static_cast<const SfxBoolItem*>(pItem)->GetValue();
419 if ( pArgs->GetItemState( SID_SORT_ATTRIBS, true, &pItem ) == SFX_ITEM_SET )
420 aSortParam.bIncludePattern = static_cast<const SfxBoolItem*>(pItem)->GetValue();
421 if ( pArgs->GetItemState( SID_SORT_USERDEF, sal_True, &pItem ) == SFX_ITEM_SET )
423 sal_uInt16 nUserIndex = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
424 aSortParam.bUserDef = ( nUserIndex != 0 );
425 if ( nUserIndex )
426 aSortParam.nUserIndex = nUserIndex - 1; // Basic: 1-based
429 SCCOLROW nField0 = 0;
430 if ( pArgs->GetItemState( FN_PARAM_1, sal_True, &pItem ) == SFX_ITEM_SET )
431 nField0 = static_cast<const SfxInt32Item*>(pItem)->GetValue();
432 aSortParam.maKeyState[0].bDoSort = ( nField0 != 0 );
433 aSortParam.maKeyState[0].nField = nField0 > 0 ? (nField0-1) : 0;
434 if ( pArgs->GetItemState( FN_PARAM_2, sal_True, &pItem ) == SFX_ITEM_SET )
435 aSortParam.maKeyState[0].bAscending = static_cast<const SfxBoolItem*>(pItem)->GetValue();
436 SCCOLROW nField1 = 0;
437 if ( pArgs->GetItemState( FN_PARAM_3, sal_True, &pItem ) == SFX_ITEM_SET )
438 nField1 = static_cast<const SfxInt32Item*>(pItem)->GetValue();
439 aSortParam.maKeyState[1].bDoSort = ( nField1 != 0 );
440 aSortParam.maKeyState[1].nField = nField1 > 0 ? (nField1-1) : 0;
441 if ( pArgs->GetItemState( FN_PARAM_4, sal_True, &pItem ) == SFX_ITEM_SET )
442 aSortParam.maKeyState[1].bAscending = static_cast<const SfxBoolItem*>(pItem)->GetValue();
443 SCCOLROW nField2 = 0;
444 if ( pArgs->GetItemState( FN_PARAM_5, sal_True, &pItem ) == SFX_ITEM_SET )
445 nField2 = static_cast<const SfxInt32Item*>(pItem)->GetValue();
446 aSortParam.maKeyState[2].bDoSort = ( nField2 != 0 );
447 aSortParam.maKeyState[2].nField = nField2 > 0 ? (nField2-1) : 0;
448 if ( pArgs->GetItemState( FN_PARAM_6, sal_True, &pItem ) == SFX_ITEM_SET )
449 aSortParam.maKeyState[2].bAscending = static_cast<const SfxBoolItem*>(pItem)->GetValue();
451 // subtotal when needed new
452 pTabViewShell->UISort( aSortParam );
453 rReq.Done();
456 else
458 ScSortParam aSortParam;
459 ScDBData* pDBData = pTabViewShell->GetDBData();
460 ScViewData* pData = GetViewData();
462 pDBData->GetSortParam( aSortParam );
464 if( lcl_GetSortParam( pData, aSortParam ) )
466 SfxAbstractTabDialog* pDlg = NULL;
467 ScDocument* pDoc = GetViewData()->GetDocument();
468 SfxItemSet aArgSet( GetPool(), SCITEM_SORTDATA, SCITEM_SORTDATA );
470 pDBData->GetSortParam( aSortParam );
471 sal_Bool bHasHeader = pDoc->HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, pData->GetTabNo() );
472 if( bHasHeader )
473 aSortParam.bHasHeader = bHasHeader;
475 aArgSet.Put( ScSortItem( SCITEM_SORTDATA, GetViewData(), &aSortParam ) );
477 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
478 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
480 pDlg = pFact->CreateScSortDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SORT );
481 OSL_ENSURE(pDlg, "Dialog create fail!");
482 pDlg->SetCurPageId(1); // 1=sort field tab 2=sort options tab
484 if ( pDlg->Execute() == RET_OK )
486 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
487 const ScSortParam& rOutParam = ((const ScSortItem&)
488 pOutSet->Get( SCITEM_SORTDATA )).GetSortData();
490 // subtotal when needed new
492 pTabViewShell->UISort( rOutParam );
494 if ( rOutParam.bInplace )
496 rReq.AppendItem( SfxBoolItem( SID_SORT_BYROW,
497 rOutParam.bByRow ) );
498 rReq.AppendItem( SfxBoolItem( SID_SORT_HASHEADER,
499 rOutParam.bHasHeader ) );
500 rReq.AppendItem( SfxBoolItem( SID_SORT_CASESENS,
501 rOutParam.bCaseSens ) );
502 rReq.AppendItem( SfxBoolItem( SID_SORT_NATURALSORT,
503 rOutParam.bNaturalSort ) );
504 rReq.AppendItem( SfxBoolItem( SID_SORT_ATTRIBS,
505 rOutParam.bIncludePattern ) );
506 sal_uInt16 nUser = rOutParam.bUserDef ? ( rOutParam.nUserIndex + 1 ) : 0;
507 rReq.AppendItem( SfxUInt16Item( SID_SORT_USERDEF, nUser ) );
508 if ( rOutParam.maKeyState[0].bDoSort )
510 rReq.AppendItem( SfxInt32Item( FN_PARAM_1,
511 rOutParam.maKeyState[0].nField + 1 ) );
512 rReq.AppendItem( SfxBoolItem( FN_PARAM_2,
513 rOutParam.maKeyState[0].bAscending ) );
515 if ( rOutParam.maKeyState[1].bDoSort )
517 rReq.AppendItem( SfxInt32Item( FN_PARAM_3,
518 rOutParam.maKeyState[1].nField + 1 ) );
519 rReq.AppendItem( SfxBoolItem( FN_PARAM_4,
520 rOutParam.maKeyState[1].bAscending ) );
522 if ( rOutParam.maKeyState[2].bDoSort )
524 rReq.AppendItem( SfxInt32Item( FN_PARAM_5,
525 rOutParam.maKeyState[2].nField + 1 ) );
526 rReq.AppendItem( SfxBoolItem( FN_PARAM_6,
527 rOutParam.maKeyState[2].bAscending ) );
531 rReq.Done();
533 else
534 GetViewData()->GetDocShell()->CancelAutoDBRange();
536 delete pDlg;
540 break;
542 case SID_FILTER:
544 const SfxItemSet* pArgs = rReq.GetArgs();
545 if ( pArgs )
547 OSL_FAIL("SID_FILTER with arguments?");
548 pTabViewShell->Query( ((const ScQueryItem&)
549 pArgs->Get( SCITEM_QUERYDATA )).GetQueryData(), NULL, sal_True );
550 rReq.Done();
552 else
554 sal_uInt16 nId = ScFilterDlgWrapper::GetChildWindowId();
555 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
556 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
558 pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
561 break;
563 case SID_SPECIAL_FILTER:
565 const SfxItemSet* pArgs = rReq.GetArgs();
566 if ( pArgs )
568 OSL_FAIL("SID_SPECIAL_FILTER with arguments?");
569 pTabViewShell->Query( ((const ScQueryItem&)
570 pArgs->Get( SCITEM_QUERYDATA )).GetQueryData(), NULL, sal_True );
571 rReq.Done();
573 else
575 sal_uInt16 nId = ScSpecialFilterDlgWrapper::GetChildWindowId();
576 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
577 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
579 pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
582 break;
584 case FID_FILTER_OK:
586 const SfxPoolItem* pItem;
587 if ( pReqArgs && SFX_ITEM_SET ==
588 pReqArgs->GetItemState( SCITEM_QUERYDATA, sal_True, &pItem ) )
590 const ScQueryItem& rQueryItem = static_cast<const ScQueryItem&>(*pItem);
592 SCTAB nCurTab = GetViewData()->GetTabNo();
593 SCTAB nRefTab = GetViewData()->GetRefTabNo();
595 // If RefInput switched to a different sheet from the data sheet,
596 // switch back:
598 if ( nCurTab != nRefTab )
600 pTabViewShell->SetTabNo( nRefTab );
601 pTabViewShell->PaintExtras();
604 ScRange aAdvSource;
605 if (rQueryItem.GetAdvancedQuerySource(aAdvSource))
606 pTabViewShell->Query( rQueryItem.GetQueryData(), &aAdvSource, sal_True );
607 else
608 pTabViewShell->Query( rQueryItem.GetQueryData(), NULL, sal_True );
609 rReq.Done( *pReqArgs );
612 break;
614 case SID_UNFILTER:
616 ScQueryParam aParam;
617 ScDBData* pDBData = pTabViewShell->GetDBData();
619 pDBData->GetQueryParam( aParam );
620 SCSIZE nEC = aParam.GetEntryCount();
621 for (SCSIZE i=0; i<nEC; i++)
622 aParam.GetEntry(i).bDoQuery = false;
623 aParam.bDuplicate = sal_True;
624 pTabViewShell->Query( aParam, NULL, sal_True );
625 rReq.Done();
627 break;
629 case SID_AUTO_FILTER:
630 pTabViewShell->ToggleAutoFilter();
631 rReq.Done();
632 break;
634 case SID_AUTOFILTER_HIDE:
635 pTabViewShell->HideAutoFilter();
636 rReq.Done();
637 break;
639 case SID_PIVOT_TABLE:
641 const SfxPoolItem* pItem;
642 if ( pReqArgs && SFX_ITEM_SET ==
643 pReqArgs->GetItemState( SCITEM_PIVOTDATA, sal_True, &pItem ) )
645 SCTAB nCurTab = GetViewData()->GetTabNo();
646 SCTAB nRefTab = GetViewData()->GetRefTabNo();
648 // If RefInput switched to a different sheet from the data sheet,
649 // switch back:
651 if ( nCurTab != nRefTab )
653 pTabViewShell->SetTabNo( nRefTab );
654 pTabViewShell->PaintExtras();
657 const ScDPObject* pDPObject = pTabViewShell->GetDialogDPObject();
658 if ( pDPObject )
660 const ScPivotItem* pPItem = (const ScPivotItem*)pItem;
661 bool bSuccess = pTabViewShell->MakePivotTable(
662 pPItem->GetData(), pPItem->GetDestRange(), pPItem->IsNewSheet(), *pDPObject );
663 SfxBoolItem aRet(0, bSuccess);
664 rReq.SetReturnValue(aRet);
666 rReq.Done();
668 #ifndef DISABLE_SCRIPTING
669 else if (rReq.IsAPI())
670 SbxBase::SetError(SbxERR_BAD_PARAMETER);
671 #endif
673 break;
675 case SID_OPENDLG_PIVOTTABLE:
676 ExecuteDataPilotDialog();
677 break;
678 case SID_DEFINE_DBNAME:
681 sal_uInt16 nId = ScDbNameDlgWrapper::GetChildWindowId();
682 SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
683 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
685 pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
688 break;
690 case SID_SELECT_DB:
692 if ( pReqArgs )
694 const SfxStringItem* pItem =
695 (const SfxStringItem*)&pReqArgs->Get( SID_SELECT_DB );
697 if( pItem )
699 pTabViewShell->GotoDBArea( pItem->GetValue() );
700 rReq.Done();
702 else
704 OSL_FAIL("NULL");
707 else
709 ScDocument* pDoc = GetViewData()->GetDocument();
710 ScDBCollection* pDBCol = pDoc->GetDBCollection();
712 if ( pDBCol )
714 std::vector<OUString> aList;
715 const ScDBCollection::NamedDBs& rDBs = pDBCol->getNamedDBs();
716 ScDBCollection::NamedDBs::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
717 for (; itr != itrEnd; ++itr)
718 aList.push_back(itr->GetName());
720 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
721 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
723 AbstractScSelEntryDlg* pDlg = pFact->CreateScSelEntryDlg( pTabViewShell->GetDialogParent(),
724 aList );
725 OSL_ENSURE(pDlg, "Dialog create fail!");
726 if ( pDlg->Execute() == RET_OK )
728 OUString aName = pDlg->GetSelectEntry();
729 pTabViewShell->GotoDBArea( aName );
730 rReq.AppendItem( SfxStringItem( SID_SELECT_DB, aName ) );
731 rReq.Done();
734 delete pDlg;
738 break;
739 case SID_DATA_STREAMS:
741 DataStreamDlg aDialog( GetViewData()->GetDocShell(), pTabViewShell->GetDialogParent() );
742 if (aDialog.Execute() == RET_OK)
743 aDialog.StartStream();
745 break;
746 case SID_DATA_STREAMS_PLAY:
748 ScDocument *pDoc = GetViewData()->GetDocument();
749 if (pDoc->GetLinkManager())
751 const sfx2::SvBaseLinks& rLinks = pDoc->GetLinkManager()->GetLinks();
752 for (size_t i = 0; i < rLinks.size(); i++)
753 if (DataStream *pStream = dynamic_cast<DataStream*>(&(*(*rLinks[i]))))
754 pStream->StartImport();
757 break;
758 case SID_DATA_STREAMS_STOP:
760 ScDocument *pDoc = GetViewData()->GetDocument();
761 if (pDoc->GetLinkManager())
763 const sfx2::SvBaseLinks& rLinks = pDoc->GetLinkManager()->GetLinks();
764 for (size_t i = 0; i < rLinks.size(); i++)
765 if (DataStream *pStream = dynamic_cast<DataStream*>(&(*(*rLinks[i]))))
766 pStream->StopImport();
769 break;
770 case SID_MANAGE_XML_SOURCE:
771 ExecuteXMLSourceDialog();
772 break;
773 case FID_VALIDATION:
775 const SfxPoolItem* pItem;
776 const SfxItemSet* pArgs = rReq.GetArgs();
777 if ( pArgs )
779 OSL_FAIL("later...");
781 else
783 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
784 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
785 ::GetTabPageRanges ScTPValidationValueGetRanges = pFact->GetTabPageRangesFunc(TP_VALIDATION_VALUES);
786 OSL_ENSURE(ScTPValidationValueGetRanges, "TabPage create fail!");
787 SfxItemSet aArgSet( GetPool(), (*ScTPValidationValueGetRanges)() );
788 ScValidationMode eMode = SC_VALID_ANY;
789 ScConditionMode eOper = SC_COND_EQUAL;
790 OUString aExpr1, aExpr2;
791 sal_Bool bBlank = sal_True;
792 sal_Int16 nListType = ValidListType::UNSORTED;
793 sal_Bool bShowHelp = false;
794 OUString aHelpTitle, aHelpText;
795 sal_Bool bShowError = false;
796 ScValidErrorStyle eErrStyle = SC_VALERR_STOP;
797 OUString aErrTitle, aErrText;
799 ScDocument* pDoc = GetViewData()->GetDocument();
800 SCCOL nCurX = GetViewData()->GetCurX();
801 SCROW nCurY = GetViewData()->GetCurY();
802 SCTAB nTab = GetViewData()->GetTabNo();
803 ScAddress aCursorPos( nCurX, nCurY, nTab );
804 sal_uLong nIndex = ((SfxUInt32Item*)pDoc->GetAttr(
805 nCurX, nCurY, nTab, ATTR_VALIDDATA ))->GetValue();
806 if ( nIndex )
808 const ScValidationData* pOldData = pDoc->GetValidationEntry( nIndex );
809 if ( pOldData )
811 eMode = pOldData->GetDataMode();
812 eOper = pOldData->GetOperation();
813 sal_uLong nNumFmt = 0;
814 if ( eMode == SC_VALID_DATE || eMode == SC_VALID_TIME )
816 short nType = ( eMode == SC_VALID_DATE ) ? NUMBERFORMAT_DATE
817 : NUMBERFORMAT_TIME;
818 nNumFmt = pDoc->GetFormatTable()->GetStandardFormat(
819 nType, ScGlobal::eLnge );
821 aExpr1 = pOldData->GetExpression( aCursorPos, 0, nNumFmt );
822 aExpr2 = pOldData->GetExpression( aCursorPos, 1, nNumFmt );
823 bBlank = pOldData->IsIgnoreBlank();
824 nListType = pOldData->GetListType();
826 bShowHelp = pOldData->GetInput( aHelpTitle, aHelpText );
827 bShowError = pOldData->GetErrMsg( aErrTitle, aErrText, eErrStyle );
829 aArgSet.Put( SfxAllEnumItem( FID_VALID_MODE, sal::static_int_cast<sal_uInt16>(eMode) ) );
830 aArgSet.Put( SfxAllEnumItem( FID_VALID_CONDMODE, sal::static_int_cast<sal_uInt16>(eOper) ) );
831 aArgSet.Put( SfxStringItem( FID_VALID_VALUE1, aExpr1 ) );
832 aArgSet.Put( SfxStringItem( FID_VALID_VALUE2, aExpr2 ) );
833 aArgSet.Put( SfxBoolItem( FID_VALID_BLANK, bBlank ) );
834 aArgSet.Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) );
835 aArgSet.Put( SfxBoolItem( FID_VALID_SHOWHELP, bShowHelp ) );
836 aArgSet.Put( SfxStringItem( FID_VALID_HELPTITLE, aHelpTitle ) );
837 aArgSet.Put( SfxStringItem( FID_VALID_HELPTEXT, aHelpText ) );
838 aArgSet.Put( SfxBoolItem( FID_VALID_SHOWERR, bShowError ) );
839 aArgSet.Put( SfxAllEnumItem( FID_VALID_ERRSTYLE, sal::static_int_cast<sal_uInt16>(eErrStyle) ) );
840 aArgSet.Put( SfxStringItem( FID_VALID_ERRTITLE, aErrTitle ) );
841 aArgSet.Put( SfxStringItem( FID_VALID_ERRTEXT, aErrText ) );
845 // cell range picker
846 SfxAbstractTabDialog* pDlg = pFact->CreateScValidationDlg( NULL, &aArgSet, TAB_DLG_VALIDATION, pTabViewShell );
847 OSL_ENSURE(pDlg, "Dialog create fail!");
849 short nResult = pDlg->Execute();
850 //When picking Cell Range, other Tab may be switched. Need restore the correct tab
851 pTabViewShell->SetTabNo( nTab );
852 if ( nResult == RET_OK )
854 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
856 if ( pOutSet->GetItemState( FID_VALID_MODE, sal_True, &pItem ) == SFX_ITEM_SET )
857 eMode = (ScValidationMode) ((const SfxAllEnumItem*)pItem)->GetValue();
858 if ( pOutSet->GetItemState( FID_VALID_CONDMODE, sal_True, &pItem ) == SFX_ITEM_SET )
859 eOper = (ScConditionMode) ((const SfxAllEnumItem*)pItem)->GetValue();
860 if ( pOutSet->GetItemState( FID_VALID_VALUE1, sal_True, &pItem ) == SFX_ITEM_SET )
862 OUString aTemp1 = ((const SfxStringItem*)pItem)->GetValue();
863 if (eMode == SC_VALID_DATE || eMode == SC_VALID_TIME)
865 sal_uInt32 nNumIndex = 0;
866 double nVal;
867 if (pDoc->GetFormatTable()->IsNumberFormat(aTemp1, nNumIndex, nVal))
868 aExpr1 = OUString( ::rtl::math::doubleToUString( nVal,
869 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
870 ScGlobal::pLocaleData->getNumDecimalSep()[0], sal_True));
871 else
872 aExpr1 = aTemp1;
874 else
875 aExpr1 = aTemp1;
877 if ( pOutSet->GetItemState( FID_VALID_VALUE2, sal_True, &pItem ) == SFX_ITEM_SET )
879 OUString aTemp2 = ((const SfxStringItem*)pItem)->GetValue();
880 if (eMode == SC_VALID_DATE || eMode == SC_VALID_TIME)
882 sal_uInt32 nNumIndex = 0;
883 double nVal;
884 if (pDoc->GetFormatTable()->IsNumberFormat(aTemp2, nNumIndex, nVal))
885 aExpr2 = OUString( ::rtl::math::doubleToUString( nVal,
886 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
887 ScGlobal::pLocaleData->getNumDecimalSep()[0], sal_True));
888 else
889 aExpr2 = aTemp2;
891 else
892 aExpr2 = aTemp2;
895 if ( pOutSet->GetItemState( FID_VALID_BLANK, sal_True, &pItem ) == SFX_ITEM_SET )
896 bBlank = ((const SfxBoolItem*)pItem)->GetValue();
897 if ( pOutSet->GetItemState( FID_VALID_LISTTYPE, sal_True, &pItem ) == SFX_ITEM_SET )
898 nListType = ((const SfxInt16Item*)pItem)->GetValue();
900 if ( pOutSet->GetItemState( FID_VALID_SHOWHELP, sal_True, &pItem ) == SFX_ITEM_SET )
901 bShowHelp = ((const SfxBoolItem*)pItem)->GetValue();
902 if ( pOutSet->GetItemState( FID_VALID_HELPTITLE, sal_True, &pItem ) == SFX_ITEM_SET )
903 aHelpTitle = ((const SfxStringItem*)pItem)->GetValue();
904 if ( pOutSet->GetItemState( FID_VALID_HELPTEXT, sal_True, &pItem ) == SFX_ITEM_SET )
905 aHelpText = ((const SfxStringItem*)pItem)->GetValue();
907 if ( pOutSet->GetItemState( FID_VALID_SHOWERR, sal_True, &pItem ) == SFX_ITEM_SET )
908 bShowError = ((const SfxBoolItem*)pItem)->GetValue();
909 if ( pOutSet->GetItemState( FID_VALID_ERRSTYLE, sal_True, &pItem ) == SFX_ITEM_SET )
910 eErrStyle = (ScValidErrorStyle) ((const SfxAllEnumItem*)pItem)->GetValue();
911 if ( pOutSet->GetItemState( FID_VALID_ERRTITLE, sal_True, &pItem ) == SFX_ITEM_SET )
912 aErrTitle = ((const SfxStringItem*)pItem)->GetValue();
913 if ( pOutSet->GetItemState( FID_VALID_ERRTEXT, sal_True, &pItem ) == SFX_ITEM_SET )
914 aErrText = ((const SfxStringItem*)pItem)->GetValue();
916 ScValidationData aData( eMode, eOper, aExpr1, aExpr2, pDoc, aCursorPos );
917 aData.SetIgnoreBlank( bBlank );
918 aData.SetListType( nListType );
920 aData.SetInput(aHelpTitle, aHelpText); // sets bShowInput to TRUE
921 if (!bShowHelp)
922 aData.ResetInput(); // reset only bShowInput
924 aData.SetError(aErrTitle, aErrText, eErrStyle); // sets bShowError to TRUE
925 if (!bShowError)
926 aData.ResetError(); // reset only bShowError
928 pTabViewShell->SetValidation( aData );
929 pTabViewShell->TestHintWindow();
930 rReq.Done( *pOutSet );
932 //after end execute from !IsModalInputMode, it is safer to delay deleting
933 //delete pDlg;
934 Application::PostUserEvent( Link( pDlg, &DelayDeleteAbstractDialog ) );
937 break;
939 case SID_TEXT_TO_COLUMNS:
941 ScViewData* pData = GetViewData();
942 OSL_ENSURE( pData, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pData is null!" );
943 ScRange aRange;
945 if ( lcl_GetTextToColumnsRange( pData, aRange ) )
947 ScDocument* pDoc = pData->GetDocument();
948 OSL_ENSURE( pDoc, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDoc is null!" );
950 ScImportExport aExport( pDoc, aRange );
951 aExport.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::None, 0, false ) );
953 // #i87703# text to columns fails with tab separator
954 aExport.SetDelimiter( static_cast< sal_Unicode >( 0 ) );
956 SvMemoryStream aStream;
957 aStream.SetStreamCharSet( RTL_TEXTENCODING_UNICODE );
958 ScImportExport::SetNoEndianSwap( aStream );
959 aExport.ExportStream( aStream, OUString(), FORMAT_STRING );
961 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
962 OSL_ENSURE( pFact, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pFact is null!" );
963 AbstractScImportAsciiDlg *pDlg = pFact->CreateScImportAsciiDlg(
964 NULL, OUString(), &aStream, SC_TEXTTOCOLUMNS);
965 OSL_ENSURE( pDlg, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDlg is null!" );
967 if ( pDlg->Execute() == RET_OK )
969 ScDocShell* pDocSh = pData->GetDocShell();
970 OSL_ENSURE( pDocSh, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDocSh is null!" );
972 OUString aUndo = ScGlobal::GetRscString( STR_UNDO_TEXTTOCOLUMNS );
973 pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
975 ScImportExport aImport( pDoc, aRange.aStart );
976 ScAsciiOptions aOptions;
977 pDlg->GetOptions( aOptions );
978 pDlg->SaveParameters();
979 aImport.SetExtOptions( aOptions );
980 aImport.SetApi( false );
981 aStream.Seek( 0 );
982 aImport.ImportStream( aStream, OUString(), FORMAT_STRING );
984 pDocSh->GetUndoManager()->LeaveListAction();
986 delete pDlg;
989 break;
993 void ScCellShell::GetDBState( SfxItemSet& rSet )
995 ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
996 ScViewData* pData = GetViewData();
997 ScDocShell* pDocSh = pData->GetDocShell();
998 ScDocument* pDoc = pDocSh->GetDocument();
999 SCCOL nPosX = pData->GetCurX();
1000 SCROW nPosY = pData->GetCurY();
1001 SCTAB nTab = pData->GetTabNo();
1003 sal_Bool bAutoFilter = false;
1004 sal_Bool bAutoFilterTested = false;
1006 SfxWhichIter aIter(rSet);
1007 sal_uInt16 nWhich = aIter.FirstWhich();
1008 while (nWhich)
1010 switch (nWhich)
1012 case SID_REFRESH_DBAREA:
1014 // imported data without selection
1015 // or filter,sort,subtotal (also without import)
1016 sal_Bool bOk = false;
1017 ScDBData* pDBData = pTabViewShell->GetDBData(false,SC_DB_OLD);
1018 if (pDBData && pDoc->GetChangeTrack() == NULL)
1020 if ( pDBData->HasImportParam() )
1021 bOk = !pDBData->HasImportSelection();
1022 else
1024 bOk = pDBData->HasQueryParam() ||
1025 pDBData->HasSortParam() ||
1026 pDBData->HasSubTotalParam();
1029 if (!bOk)
1030 rSet.DisableItem( nWhich );
1032 break;
1034 case SID_FILTER:
1035 case SID_SPECIAL_FILTER:
1037 ScRange aDummy;
1038 ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy);
1039 if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
1041 rSet.DisableItem( nWhich );
1044 break;
1047 //in case of Redlining and multiselection disable
1048 case SID_SORT_ASCENDING:
1049 case SID_SORT_DESCENDING:
1050 case SCITEM_SORTDATA:
1051 case SCITEM_SUBTDATA:
1052 case SID_OPENDLG_PIVOTTABLE:
1054 //! move ReadOnly check to idl flags
1056 if ( pDocSh->IsReadOnly() || pDoc->GetChangeTrack()!=NULL ||
1057 GetViewData()->IsMultiMarked() )
1059 rSet.DisableItem( nWhich );
1062 break;
1064 case SID_REIMPORT_DATA:
1066 // only imported data without selection
1067 ScDBData* pDBData = pTabViewShell->GetDBData(false,SC_DB_OLD);
1068 if (!pDBData || !pDBData->HasImportParam() || pDBData->HasImportSelection() ||
1069 pDoc->GetChangeTrack()!=NULL)
1071 rSet.DisableItem( nWhich );
1074 break;
1076 case SID_VIEW_DATA_SOURCE_BROWSER:
1078 if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE))
1079 rSet.Put(SfxVisibilityItem(nWhich, false));
1080 else
1081 // get state (BoolItem) from SfxViewFrame
1082 pTabViewShell->GetViewFrame()->GetSlotState( nWhich, NULL, &rSet );
1084 break;
1085 case SID_SBA_BRW_INSERT:
1087 // SBA wants a sal_Bool-item, enabled
1089 sal_Bool bEnable = sal_True;
1090 rSet.Put(SfxBoolItem(nWhich, bEnable));
1092 break;
1094 case SID_AUTO_FILTER:
1095 case SID_AUTOFILTER_HIDE:
1097 if (!bAutoFilterTested)
1099 bAutoFilter = pDoc->HasAutoFilter( nPosX, nPosY, nTab );
1100 bAutoFilterTested = sal_True;
1102 if ( nWhich == SID_AUTO_FILTER )
1104 ScRange aDummy;
1105 ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy);
1106 if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
1108 rSet.DisableItem( nWhich );
1110 else if (pDoc->GetDPAtBlock(aDummy))
1112 rSet.DisableItem( nWhich );
1114 else
1115 rSet.Put( SfxBoolItem( nWhich, bAutoFilter ) );
1117 else
1118 if (!bAutoFilter)
1119 rSet.DisableItem( nWhich );
1121 break;
1123 case SID_UNFILTER:
1125 SCCOL nStartCol, nEndCol;
1126 SCROW nStartRow, nEndRow;
1127 SCTAB nStartTab, nEndTab;
1128 sal_Bool bAnyQuery = false;
1130 sal_Bool bSelected = (GetViewData()->GetSimpleArea(
1131 nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab )
1132 == SC_MARK_SIMPLE);
1134 if ( bSelected )
1136 if (nStartCol==nEndCol && nStartRow==nEndRow)
1137 bSelected = false;
1139 else
1141 nStartCol = GetViewData()->GetCurX();
1142 nStartRow = GetViewData()->GetCurY();
1143 nStartTab = GetViewData()->GetTabNo();
1146 ScDBData* pDBData = bSelected
1147 ? pDoc->GetDBAtArea( nStartTab, nStartCol, nStartRow, nEndCol, nEndRow )
1148 : pDoc->GetDBAtCursor( nStartCol, nStartRow, nStartTab );
1150 if ( pDBData )
1152 ScQueryParam aParam;
1153 pDBData->GetQueryParam( aParam );
1154 if ( aParam.GetEntry(0).bDoQuery )
1155 bAnyQuery = sal_True;
1158 if ( !bAnyQuery )
1159 rSet.DisableItem( nWhich );
1161 break;
1163 case SID_DEFINE_DBNAME:
1165 if ( pDocSh && pDocSh->IsDocShared() )
1167 rSet.DisableItem( nWhich );
1170 break;
1171 case SID_DATA_STREAMS:
1172 case SID_DATA_STREAMS_PLAY:
1173 case SID_DATA_STREAMS_STOP:
1175 SvtMiscOptions aMiscOptions;
1176 if ( !aMiscOptions.IsExperimentalMode() )
1177 rSet.DisableItem( nWhich );
1179 break;
1180 case SID_TEXT_TO_COLUMNS:
1182 ScRange aRange;
1183 if ( !lcl_GetTextToColumnsRange( pData, aRange ) )
1185 rSet.DisableItem( nWhich );
1188 break;
1189 #if !ENABLE_ORCUS
1190 case SID_MANAGE_XML_SOURCE:
1191 rSet.DisableItem(nWhich);
1192 break;
1193 #endif
1195 nWhich = aIter.NextWhich();
1201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */