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" // Core
42 #include "autofmt.hxx" // Dialog
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" // Input Status Edit-Zellen
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 //------------------------------------------------------------------
66 void ScTabViewShell::SetCurRefDlgId( sal_uInt16 nNew
)
68 // CurRefDlgId is stored in ScModule to find if a ref dialog is open,
69 // and in the view to identify the view that has opened the dialog
73 //ugly hack to call Define Name from Manage Names
74 void ScTabViewShell::SwitchBetweenRefDialogs(SfxModelessDialog
* pDialog
)
76 sal_uInt16 nSlotId
= SC_MOD()->GetCurRefDlgId();
77 if (nSlotId
== FID_DEFINE_NAME
)
80 static_cast<ScNameDlg
*>(pDialog
)->GetRangeNames(maRangeMap
);
81 static_cast<ScNameDlg
*>(pDialog
)->Close();
82 sal_uInt16 nId
= ScNameDefDlgWrapper::GetChildWindowId();
83 SfxViewFrame
* pViewFrm
= GetViewFrame();
84 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
86 SC_MOD()->SetRefDialog( nId
, pWnd
? false : sal_True
);
88 else if( nSlotId
== FID_ADD_NAME
)
90 static_cast<ScNameDefDlg
*>(pDialog
)->GetNewData(maName
, maScope
);
91 static_cast<ScNameDlg
*>(pDialog
)->Close();
92 sal_uInt16 nId
= ScNameDlgWrapper::GetChildWindowId();
93 SfxViewFrame
* pViewFrm
= GetViewFrame();
94 SfxChildWindow
* pWnd
= pViewFrm
->GetChildWindow( nId
);
96 SC_MOD()->SetRefDialog( nId
, pWnd
? false : sal_True
);
104 SfxModelessDialog
* ScTabViewShell::CreateRefDialog(
105 SfxBindings
* pB
, SfxChildWindow
* pCW
, SfxChildWinInfo
* pInfo
,
106 Window
* pParent
, sal_uInt16 nSlotId
)
108 // Dialog nur aufmachen, wenn ueber ScModule::SetRefDialog gerufen, damit
109 // z.B. nach einem Absturz offene Ref-Dialoge nicht wiederkommen (#42341#).
111 if ( SC_MOD()->GetCurRefDlgId() != nSlotId
)
114 if ( nCurRefDlgId
!= nSlotId
)
116 // the dialog has been opened in a different view
117 // -> lock the dispatcher for this view (modal mode)
119 GetViewData()->GetDispatcher().Lock( sal_True
); // lock is reset when closing dialog
123 SfxModelessDialog
* pResult
= 0;
126 pCW
->SetHideNotDelete(sal_True
);
128 ScDocument
* pDoc
= GetViewData()->GetDocument();
132 case FID_DEFINE_NAME
:
136 pResult
= new ScNameDlg( pB
, pCW
, pParent
, GetViewData(),
137 ScAddress( GetViewData()->GetCurX(),
138 GetViewData()->GetCurY(),
139 GetViewData()->GetTabNo() ) );
143 pResult
= new ScNameDlg( pB
, pCW
, pParent
, GetViewData(),
144 ScAddress( GetViewData()->GetCurX(),
145 GetViewData()->GetCurY(),
146 GetViewData()->GetTabNo() ), &maRangeMap
);
147 static_cast<ScNameDlg
*>(pResult
)->SetEntry( maName
, maScope
);
157 std::map
<OUString
, ScRangeName
*> aRangeMap
;
158 pDoc
->GetRangeNameMap(aRangeMap
);
159 pResult
= new ScNameDefDlg( pB
, pCW
, pParent
, GetViewData(), aRangeMap
,
160 ScAddress( GetViewData()->GetCurX(),
161 GetViewData()->GetCurY(),
162 GetViewData()->GetTabNo() ), true );
166 std::map
<OUString
, ScRangeName
*> aRangeMap
;
167 for (boost::ptr_map
<OUString
, ScRangeName
>::iterator itr
= maRangeMap
.begin();
168 itr
!= maRangeMap
.end(); ++itr
)
170 aRangeMap
.insert(std::pair
<OUString
, ScRangeName
*>(itr
->first
, itr
->second
));
172 pResult
= new ScNameDefDlg( pB
, pCW
, pParent
, GetViewData(), aRangeMap
,
173 ScAddress( GetViewData()->GetCurX(),
174 GetViewData()->GetCurY(),
175 GetViewData()->GetTabNo() ), false );
180 case SID_DEFINE_COLROWNAMERANGES
:
182 pResult
= new ScColRowNameRangesDlg( pB
, pCW
, pParent
, GetViewData() );
186 case SID_OPENDLG_CONSOLIDATE
:
188 SfxItemSet
aArgSet( GetPool(),
189 SCITEM_CONSOLIDATEDATA
,
190 SCITEM_CONSOLIDATEDATA
);
192 const ScConsolidateParam
* pDlgData
=
193 pDoc
->GetConsolidateDlgData();
197 ScConsolidateParam aConsParam
;
198 SCCOL nStartCol
, nEndCol
;
199 SCROW nStartRow
, nEndRow
;
200 SCTAB nStartTab
, nEndTab
;
202 GetViewData()->GetSimpleArea( nStartCol
, nStartRow
, nStartTab
,
203 nEndCol
, nEndRow
, nEndTab
);
205 PutInOrder( nStartCol
, nEndCol
);
206 PutInOrder( nStartRow
, nEndRow
);
207 PutInOrder( nStartTab
, nEndTab
);
209 aConsParam
.nCol
= nStartCol
;
210 aConsParam
.nRow
= nStartRow
;
211 aConsParam
.nTab
= nStartTab
;
213 aArgSet
.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA
,
218 aArgSet
.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA
, pDlgData
) );
220 pResult
= new ScConsolidateDlg( pB
, pCW
, pParent
, aArgSet
);
224 case SID_DEFINE_DBNAME
:
226 // wenn auf einem bestehenden Bereich aufgerufen, den markieren
227 GetDBData( sal_True
, SC_DB_OLD
);
228 const ScMarkData
& rMark
= GetViewData()->GetMarkData();
229 if ( !rMark
.IsMarked() && !rMark
.IsMultiMarked() )
230 MarkDataArea( false );
232 pResult
= new ScDbNameDlg( pB
, pCW
, pParent
, GetViewData() );
236 case SID_SPECIAL_FILTER
:
238 ScQueryParam aQueryParam
;
239 SfxItemSet
aArgSet( GetPool(),
243 ScDBData
* pDBData
= GetDBData(false, SC_DB_MAKE
, SC_DBSEL_ROW_DOWN
);
244 pDBData
->ExtendDataArea(pDoc
);
245 pDBData
->GetQueryParam( aQueryParam
);
248 pDBData
->GetArea(aArea
);
249 MarkRange(aArea
, false);
251 ScQueryItem
aItem( SCITEM_QUERYDATA
, GetViewData(), &aQueryParam
);
253 if (pDBData
->GetAdvancedQuerySource(aAdvSource
))
254 aItem
.SetAdvancedQuerySource( &aAdvSource
);
256 aArgSet
.Put( aItem
);
258 // aktuelle Tabelle merken (wg. RefInput im Dialog)
259 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
261 pResult
= new ScSpecialFilterDlg( pB
, pCW
, pParent
, aArgSet
);
268 ScQueryParam aQueryParam
;
269 SfxItemSet
aArgSet( GetPool(),
273 ScDBData
* pDBData
= GetDBData(false, SC_DB_MAKE
, SC_DBSEL_ROW_DOWN
);
274 pDBData
->ExtendDataArea(pDoc
);
275 pDBData
->GetQueryParam( aQueryParam
);
278 pDBData
->GetArea(aArea
);
279 MarkRange(aArea
, false);
281 aArgSet
.Put( ScQueryItem( SCITEM_QUERYDATA
,
285 // aktuelle Tabelle merken (wg. RefInput im Dialog)
286 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
288 pResult
= new ScFilterDlg( pB
, pCW
, pParent
, aArgSet
);
292 case SID_OPENDLG_TABOP
:
294 ScViewData
* pViewData
= GetViewData();
295 ScRefAddress
aCurPos ( pViewData
->GetCurX(),
296 pViewData
->GetCurY(),
297 pViewData
->GetTabNo(),
298 false, false, false );
300 pResult
= new ScTabOpDlg( pB
, pCW
, pParent
, pViewData
->GetDocument(), aCurPos
);
304 case SID_OPENDLG_SOLVE
:
306 ScViewData
* pViewData
= GetViewData();
307 ScAddress
aCurPos( pViewData
->GetCurX(),
308 pViewData
->GetCurY(),
309 pViewData
->GetTabNo());
310 pResult
= new ScSolverDlg( pB
, pCW
, pParent
, pViewData
->GetDocument(), aCurPos
);
314 case SID_OPENDLG_OPTSOLVER
:
316 ScViewData
* pViewData
= GetViewData();
317 ScAddress
aCurPos( pViewData
->GetCurX(), pViewData
->GetCurY(), pViewData
->GetTabNo());
318 pResult
= new ScOptSolverDlg( pB
, pCW
, pParent
, pViewData
->GetDocShell(), aCurPos
);
322 case SID_OPENDLG_PIVOTTABLE
:
324 #if ! MPL_HAVE_SUBSET
325 // all settings must be in pDialogDPObject
327 if( pDialogDPObject
)
329 // Check for an existing datapilot output.
330 ScViewData
* pViewData
= GetViewData();
331 ScDPObject
* pObj
= pDoc
->GetDPAtCursor(
332 pViewData
->GetCurX(), pViewData
->GetCurY(), pViewData
->GetTabNo());
334 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
335 pResult
= new ScPivotLayoutDlg( pB
, pCW
, pParent
, *pDialogDPObject
, pObj
== NULL
);
341 case SID_OPENDLG_EDIT_PRINTAREA
:
343 pResult
= new ScPrintAreasDlg( pB
, pCW
, pParent
);
347 case SID_OPENDLG_FUNCTION
:
349 // Dialog schaut selber, was in der Zelle steht
351 pResult
= new ScFormulaDlg( pB
, pCW
, pParent
, GetViewData(),ScGlobal::GetStarCalcFunctionMgr() );
355 case SID_MANAGE_XML_SOURCE
:
357 pResult
= new ScXMLSourceDlg(pB
, pCW
, pParent
, pDoc
);
363 // Dialog schaut selber, was in der Zelle steht
365 pResult
= new ScHighlightChgDlg( pB
, pCW
, pParent
, GetViewData() );
371 // Dialog schaut selber, was in der Zelle steht
373 ScViewData
* pViewData
= GetViewData();
374 pViewData
->SetRefTabNo( pViewData
->GetTabNo() );
375 pResult
= new ScSimpleRefDlg( pB
, pCW
, pParent
, pViewData
);
381 OSL_FAIL( "ScTabViewShell::CreateRefDialog: unbekannte ID" );
387 // Die Dialoge gehen immer mit eingeklapptem Zusaetze-Button auf,
388 // darum muss die Groesse ueber das Initialize gerettet werden
389 // (oder den Zusaetze-Status mit speichern !!!)
391 Size aSize
= pResult
->GetSizePixel();
392 pResult
->Initialize( pInfo
);
393 pResult
->SetSizePixel(aSize
);
401 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */