GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / sc / source / ui / view / tabvwshc.cxx
bloba91377c141a153e80d87b092e49c5811ed798974
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 <config_mpl.h>
22 #include "scitems.hxx"
23 #include <vcl/msgbox.hxx>
24 #include <sfx2/childwin.hxx>
25 #include <sfx2/dispatch.hxx>
27 #include "tabvwsh.hxx"
28 #include "sc.hrc"
29 #include "globstr.hrc"
30 #include "global.hxx"
31 #include "scmod.hxx"
32 #include "docsh.hxx"
33 #include "document.hxx"
34 #include "uiitems.hxx"
35 #include "pivot.hxx"
36 #include "namedlg.hxx"
37 #include "namedefdlg.hxx"
38 #include "solvrdlg.hxx"
39 #include "optsolver.hxx"
40 #include "tabopdlg.hxx"
41 #include "autoform.hxx"
42 #include "autofmt.hxx"
43 #include "consdlg.hxx"
44 #include "filtdlg.hxx"
45 #include "dbnamdlg.hxx"
46 #if ! MPL_HAVE_SUBSET
47 # include "pvlaydlg.hxx"
48 #endif
49 #include "areasdlg.hxx"
50 #include "rangeutl.hxx"
51 #include "crnrdlg.hxx"
52 #include "formula.hxx"
53 #include "formulacell.hxx"
54 #include "acredlin.hxx"
55 #include "highred.hxx"
56 #include "simpref.hxx"
57 #include "funcdesc.hxx"
58 #include "dpobject.hxx"
59 #include "markdata.hxx"
60 #include "reffact.hxx"
61 #include "condformatdlg.hxx"
62 #include "xmlsourcedlg.hxx"
64 #include "RandomNumberGeneratorDialog.hxx"
65 #include "SamplingDialog.hxx"
66 #include "DescriptiveStatisticsDialog.hxx"
67 #include "AnalysisOfVarianceDialog.hxx"
68 #include "CorrelationDialog.hxx"
69 #include "CovarianceDialog.hxx"
70 #include "ExponentialSmoothingDialog.hxx"
71 #include "MovingAverageDialog.hxx"
73 #include <config_orcus.h>
75 //------------------------------------------------------------------
77 void ScTabViewShell::SetCurRefDlgId( sal_uInt16 nNew )
79 // CurRefDlgId is stored in ScModule to find if a ref dialog is open,
80 // and in the view to identify the view that has opened the dialog
81 nCurRefDlgId = nNew;
84 //ugly hack to call Define Name from Manage Names
85 void ScTabViewShell::SwitchBetweenRefDialogs(SfxModelessDialog* pDialog)
87 sal_uInt16 nSlotId = SC_MOD()->GetCurRefDlgId();
88 if (nSlotId == FID_DEFINE_NAME)
90 mbInSwitch = true;
91 static_cast<ScNameDlg*>(pDialog)->GetRangeNames(maRangeMap);
92 static_cast<ScNameDlg*>(pDialog)->Close();
93 sal_uInt16 nId = ScNameDefDlgWrapper::GetChildWindowId();
94 SfxViewFrame* pViewFrm = GetViewFrame();
95 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
97 SC_MOD()->SetRefDialog( nId, pWnd ? false : sal_True );
99 else if( nSlotId == FID_ADD_NAME )
101 static_cast<ScNameDefDlg*>(pDialog)->GetNewData(maName, maScope);
102 static_cast<ScNameDlg*>(pDialog)->Close();
103 sal_uInt16 nId = ScNameDlgWrapper::GetChildWindowId();
104 SfxViewFrame* pViewFrm = GetViewFrame();
105 SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
107 SC_MOD()->SetRefDialog( nId, pWnd ? false : sal_True );
109 else
115 SfxModelessDialog* ScTabViewShell::CreateRefDialog(
116 SfxBindings* pB, SfxChildWindow* pCW, SfxChildWinInfo* pInfo,
117 Window* pParent, sal_uInt16 nSlotId )
119 // Dialog nur aufmachen, wenn ueber ScModule::SetRefDialog gerufen, damit
120 // z.B. nach einem Absturz offene Ref-Dialoge nicht wiederkommen (#42341#).
122 if ( SC_MOD()->GetCurRefDlgId() != nSlotId )
123 return NULL;
125 if ( nCurRefDlgId != nSlotId )
127 // the dialog has been opened in a different view
128 // -> lock the dispatcher for this view (modal mode)
130 GetViewData()->GetDispatcher().Lock( sal_True ); // lock is reset when closing dialog
131 return NULL;
134 SfxModelessDialog* pResult = 0;
136 if(pCW)
137 pCW->SetHideNotDelete(sal_True);
139 ScDocument* pDoc = GetViewData()->GetDocument();
141 switch( nSlotId )
143 case FID_DEFINE_NAME:
145 if (!mbInSwitch)
147 pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(),
148 ScAddress( GetViewData()->GetCurX(),
149 GetViewData()->GetCurY(),
150 GetViewData()->GetTabNo() ) );
152 else
154 pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(),
155 ScAddress( GetViewData()->GetCurX(),
156 GetViewData()->GetCurY(),
157 GetViewData()->GetTabNo() ), &maRangeMap);
158 static_cast<ScNameDlg*>(pResult)->SetEntry( maName, maScope);
159 mbInSwitch = false;
162 break;
164 case FID_ADD_NAME:
166 if (!mbInSwitch)
168 std::map<OUString, ScRangeName*> aRangeMap;
169 pDoc->GetRangeNameMap(aRangeMap);
170 pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData(), aRangeMap,
171 ScAddress( GetViewData()->GetCurX(),
172 GetViewData()->GetCurY(),
173 GetViewData()->GetTabNo() ), true );
175 else
177 std::map<OUString, ScRangeName*> aRangeMap;
178 for (boost::ptr_map<OUString, ScRangeName>::iterator itr = maRangeMap.begin();
179 itr != maRangeMap.end(); ++itr)
181 aRangeMap.insert(std::pair<OUString, ScRangeName*>(itr->first, itr->second));
183 pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData(), aRangeMap,
184 ScAddress( GetViewData()->GetCurX(),
185 GetViewData()->GetCurY(),
186 GetViewData()->GetTabNo() ), false );
189 break;
191 case SID_DEFINE_COLROWNAMERANGES:
193 pResult = new ScColRowNameRangesDlg( pB, pCW, pParent, GetViewData() );
195 break;
197 case SID_OPENDLG_CONSOLIDATE:
199 SfxItemSet aArgSet( GetPool(),
200 SCITEM_CONSOLIDATEDATA,
201 SCITEM_CONSOLIDATEDATA );
203 const ScConsolidateParam* pDlgData =
204 pDoc->GetConsolidateDlgData();
206 if ( !pDlgData )
208 ScConsolidateParam aConsParam;
209 SCCOL nStartCol, nEndCol;
210 SCROW nStartRow, nEndRow;
211 SCTAB nStartTab, nEndTab;
213 GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab,
214 nEndCol, nEndRow, nEndTab );
216 PutInOrder( nStartCol, nEndCol );
217 PutInOrder( nStartRow, nEndRow );
218 PutInOrder( nStartTab, nEndTab );
220 aConsParam.nCol = nStartCol;
221 aConsParam.nRow = nStartRow;
222 aConsParam.nTab = nStartTab;
224 aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA,
225 &aConsParam ) );
227 else
229 aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA, pDlgData ) );
231 pResult = new ScConsolidateDlg( pB, pCW, pParent, aArgSet );
233 break;
235 case SID_DEFINE_DBNAME:
237 // wenn auf einem bestehenden Bereich aufgerufen, den markieren
238 GetDBData( sal_True, SC_DB_OLD );
239 const ScMarkData& rMark = GetViewData()->GetMarkData();
240 if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
241 MarkDataArea( false );
243 pResult = new ScDbNameDlg( pB, pCW, pParent, GetViewData() );
245 break;
247 case SID_SPECIAL_FILTER:
249 ScQueryParam aQueryParam;
250 SfxItemSet aArgSet( GetPool(),
251 SCITEM_QUERYDATA,
252 SCITEM_QUERYDATA );
254 ScDBData* pDBData = GetDBData(false, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
255 pDBData->ExtendDataArea(pDoc);
256 pDBData->GetQueryParam( aQueryParam );
258 ScRange aArea;
259 pDBData->GetArea(aArea);
260 MarkRange(aArea, false);
262 ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam );
263 ScRange aAdvSource;
264 if (pDBData->GetAdvancedQuerySource(aAdvSource))
265 aItem.SetAdvancedQuerySource( &aAdvSource );
267 aArgSet.Put( aItem );
269 // aktuelle Tabelle merken (wg. RefInput im Dialog)
270 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
272 pResult = new ScSpecialFilterDlg( pB, pCW, pParent, aArgSet );
274 break;
276 case SID_FILTER:
279 ScQueryParam aQueryParam;
280 SfxItemSet aArgSet( GetPool(),
281 SCITEM_QUERYDATA,
282 SCITEM_QUERYDATA );
284 ScDBData* pDBData = GetDBData(false, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
285 pDBData->ExtendDataArea(pDoc);
286 pDBData->GetQueryParam( aQueryParam );
288 ScRange aArea;
289 pDBData->GetArea(aArea);
290 MarkRange(aArea, false);
292 aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA,
293 GetViewData(),
294 &aQueryParam ) );
296 // aktuelle Tabelle merken (wg. RefInput im Dialog)
297 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
299 pResult = new ScFilterDlg( pB, pCW, pParent, aArgSet );
301 break;
303 case SID_OPENDLG_TABOP:
305 ScViewData* pViewData = GetViewData();
306 ScRefAddress aCurPos ( pViewData->GetCurX(),
307 pViewData->GetCurY(),
308 pViewData->GetTabNo(),
309 false, false, false );
311 pResult = new ScTabOpDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos );
313 break;
315 case SID_OPENDLG_SOLVE:
317 ScViewData* pViewData = GetViewData();
318 ScAddress aCurPos( pViewData->GetCurX(),
319 pViewData->GetCurY(),
320 pViewData->GetTabNo());
321 pResult = new ScSolverDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos );
323 break;
325 case SID_RANDOM_NUMBER_GENERATOR_DIALOG:
327 pResult = new ScRandomNumberGeneratorDialog( pB, pCW, pParent, GetViewData() );
329 break;
331 case SID_SAMPLING_DIALOG:
333 pResult = new ScSamplingDialog( pB, pCW, pParent, GetViewData() );
335 break;
337 case SID_DESCRIPTIVE_STATISTICS_DIALOG:
339 pResult = new ScDescriptiveStatisticsDialog( pB, pCW, pParent, GetViewData() );
341 break;
343 case SID_ANALYSIS_OF_VARIANCE_DIALOG:
345 pResult = new ScAnalysisOfVarianceDialog( pB, pCW, pParent, GetViewData() );
347 break;
349 case SID_CORRELATION_DIALOG:
351 pResult = new ScCorrelationDialog( pB, pCW, pParent, GetViewData() );
353 break;
355 case SID_COVARIANCE_DIALOG:
357 pResult = new ScCovarianceDialog( pB, pCW, pParent, GetViewData() );
359 break;
361 case SID_EXPONENTIAL_SMOOTHING_DIALOG:
363 pResult = new ScExponentialSmoothingDialog( pB, pCW, pParent, GetViewData() );
365 break;
367 case SID_MOVING_AVERAGE_DIALOG:
369 pResult = new ScMovingAverageDialog( pB, pCW, pParent, GetViewData() );
371 break;
373 case SID_OPENDLG_OPTSOLVER:
375 ScViewData* pViewData = GetViewData();
376 ScAddress aCurPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
377 pResult = new ScOptSolverDlg( pB, pCW, pParent, pViewData->GetDocShell(), aCurPos );
379 break;
381 case SID_OPENDLG_PIVOTTABLE:
383 #if ! MPL_HAVE_SUBSET
384 // all settings must be in pDialogDPObject
386 if( pDialogDPObject )
388 // Check for an existing datapilot output.
389 ScViewData* pViewData = GetViewData();
390 ScDPObject* pObj = pDoc->GetDPAtCursor(
391 pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
393 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
394 pResult = new ScPivotLayoutDlg( pB, pCW, pParent, *pDialogDPObject, pObj == NULL);
396 #endif
398 break;
400 case SID_OPENDLG_EDIT_PRINTAREA:
402 pResult = new ScPrintAreasDlg( pB, pCW, pParent );
404 break;
406 case SID_OPENDLG_FUNCTION:
408 // Dialog schaut selber, was in der Zelle steht
410 pResult = new ScFormulaDlg( pB, pCW, pParent, GetViewData(),ScGlobal::GetStarCalcFunctionMgr() );
412 break;
414 case SID_MANAGE_XML_SOURCE:
416 #if ENABLE_ORCUS
417 pResult = new ScXMLSourceDlg(pB, pCW, pParent, pDoc);
418 #endif
420 break;
422 case FID_CHG_SHOW:
424 // Dialog schaut selber, was in der Zelle steht
426 pResult = new ScHighlightChgDlg( pB, pCW, pParent, GetViewData() );
428 break;
430 case WID_SIMPLE_REF:
432 // Dialog schaut selber, was in der Zelle steht
434 ScViewData* pViewData = GetViewData();
435 pViewData->SetRefTabNo( pViewData->GetTabNo() );
436 pResult = new ScSimpleRefDlg( pB, pCW, pParent, pViewData );
438 break;
441 default:
442 OSL_FAIL( "ScTabViewShell::CreateRefDialog: unbekannte ID" );
443 break;
446 if (pResult)
448 // Die Dialoge gehen immer mit eingeklapptem Zusaetze-Button auf,
449 // darum muss die Groesse ueber das Initialize gerettet werden
450 // (oder den Zusaetze-Status mit speichern !!!)
452 Size aSize = pResult->GetSizePixel();
453 pResult->Initialize( pInfo );
454 pResult->SetSizePixel(aSize);
457 return pResult;
462 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */