1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
29 #include "globstr.hrc"
33 #include "document.hxx"
34 #include "uiitems.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"
47 # include "pvlaydlg.hxx"
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
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
)
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
);
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
)
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
134 SfxModelessDialog
* pResult
= 0;
137 pCW
->SetHideNotDelete(sal_True
);
139 ScDocument
* pDoc
= GetViewData()->GetDocument();
143 case FID_DEFINE_NAME
:
147 pResult
= new ScNameDlg( pB
, pCW
, pParent
, GetViewData(),
148 ScAddress( GetViewData()->GetCurX(),
149 GetViewData()->GetCurY(),
150 GetViewData()->GetTabNo() ) );
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
);
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 );
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 );
191 case SID_DEFINE_COLROWNAMERANGES
:
193 pResult
= new ScColRowNameRangesDlg( pB
, pCW
, pParent
, GetViewData() );
197 case SID_OPENDLG_CONSOLIDATE
:
199 SfxItemSet
aArgSet( GetPool(),
200 SCITEM_CONSOLIDATEDATA
,
201 SCITEM_CONSOLIDATEDATA
);
203 const ScConsolidateParam
* pDlgData
=
204 pDoc
->GetConsolidateDlgData();
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
,
229 aArgSet
.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA
, pDlgData
) );
231 pResult
= new ScConsolidateDlg( pB
, pCW
, pParent
, aArgSet
);
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() );
247 case SID_SPECIAL_FILTER
:
249 ScQueryParam aQueryParam
;
250 SfxItemSet
aArgSet( GetPool(),
254 ScDBData
* pDBData
= GetDBData(false, SC_DB_MAKE
, SC_DBSEL_ROW_DOWN
);
255 pDBData
->ExtendDataArea(pDoc
);
256 pDBData
->GetQueryParam( aQueryParam
);
259 pDBData
->GetArea(aArea
);
260 MarkRange(aArea
, false);
262 ScQueryItem
aItem( SCITEM_QUERYDATA
, GetViewData(), &aQueryParam
);
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
);
279 ScQueryParam aQueryParam
;
280 SfxItemSet
aArgSet( GetPool(),
284 ScDBData
* pDBData
= GetDBData(false, SC_DB_MAKE
, SC_DBSEL_ROW_DOWN
);
285 pDBData
->ExtendDataArea(pDoc
);
286 pDBData
->GetQueryParam( aQueryParam
);
289 pDBData
->GetArea(aArea
);
290 MarkRange(aArea
, false);
292 aArgSet
.Put( ScQueryItem( SCITEM_QUERYDATA
,
296 // aktuelle Tabelle merken (wg. RefInput im Dialog)
297 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
299 pResult
= new ScFilterDlg( pB
, pCW
, pParent
, aArgSet
);
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
);
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
);
325 case SID_RANDOM_NUMBER_GENERATOR_DIALOG
:
327 pResult
= new ScRandomNumberGeneratorDialog( pB
, pCW
, pParent
, GetViewData() );
331 case SID_SAMPLING_DIALOG
:
333 pResult
= new ScSamplingDialog( pB
, pCW
, pParent
, GetViewData() );
337 case SID_DESCRIPTIVE_STATISTICS_DIALOG
:
339 pResult
= new ScDescriptiveStatisticsDialog( pB
, pCW
, pParent
, GetViewData() );
343 case SID_ANALYSIS_OF_VARIANCE_DIALOG
:
345 pResult
= new ScAnalysisOfVarianceDialog( pB
, pCW
, pParent
, GetViewData() );
349 case SID_CORRELATION_DIALOG
:
351 pResult
= new ScCorrelationDialog( pB
, pCW
, pParent
, GetViewData() );
355 case SID_COVARIANCE_DIALOG
:
357 pResult
= new ScCovarianceDialog( pB
, pCW
, pParent
, GetViewData() );
361 case SID_EXPONENTIAL_SMOOTHING_DIALOG
:
363 pResult
= new ScExponentialSmoothingDialog( pB
, pCW
, pParent
, GetViewData() );
367 case SID_MOVING_AVERAGE_DIALOG
:
369 pResult
= new ScMovingAverageDialog( pB
, pCW
, pParent
, GetViewData() );
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
);
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
);
400 case SID_OPENDLG_EDIT_PRINTAREA
:
402 pResult
= new ScPrintAreasDlg( pB
, pCW
, pParent
);
406 case SID_OPENDLG_FUNCTION
:
408 // Dialog schaut selber, was in der Zelle steht
410 pResult
= new ScFormulaDlg( pB
, pCW
, pParent
, GetViewData(),ScGlobal::GetStarCalcFunctionMgr() );
414 case SID_MANAGE_XML_SOURCE
:
417 pResult
= new ScXMLSourceDlg(pB
, pCW
, pParent
, pDoc
);
424 // Dialog schaut selber, was in der Zelle steht
426 pResult
= new ScHighlightChgDlg( pB
, pCW
, pParent
, GetViewData() );
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
);
442 OSL_FAIL( "ScTabViewShell::CreateRefDialog: unbekannte ID" );
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
);
462 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */