Line data Source code
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_mpl.h>
21 :
22 : #include "scitems.hxx"
23 : #include <vcl/msgbox.hxx>
24 : #include <sfx2/childwin.hxx>
25 : #include <sfx2/dispatch.hxx>
26 :
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" // Core
42 : #include "autofmt.hxx" // Dialog
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" // 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"
63 :
64 : //------------------------------------------------------------------
65 :
66 0 : void ScTabViewShell::SetCurRefDlgId( sal_uInt16 nNew )
67 : {
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
70 0 : nCurRefDlgId = nNew;
71 0 : }
72 :
73 : //ugly hack to call Define Name from Manage Names
74 0 : void ScTabViewShell::SwitchBetweenRefDialogs(SfxModelessDialog* pDialog)
75 : {
76 0 : sal_uInt16 nSlotId = SC_MOD()->GetCurRefDlgId();
77 0 : if (nSlotId == FID_DEFINE_NAME)
78 : {
79 0 : mbInSwitch = true;
80 0 : static_cast<ScNameDlg*>(pDialog)->GetRangeNames(maRangeMap);
81 0 : static_cast<ScNameDlg*>(pDialog)->Close();
82 0 : sal_uInt16 nId = ScNameDefDlgWrapper::GetChildWindowId();
83 0 : SfxViewFrame* pViewFrm = GetViewFrame();
84 0 : SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
85 :
86 0 : SC_MOD()->SetRefDialog( nId, pWnd ? false : sal_True );
87 : }
88 0 : else if( nSlotId == FID_ADD_NAME )
89 : {
90 0 : static_cast<ScNameDefDlg*>(pDialog)->GetNewData(maName, maScope);
91 0 : static_cast<ScNameDlg*>(pDialog)->Close();
92 0 : sal_uInt16 nId = ScNameDlgWrapper::GetChildWindowId();
93 0 : SfxViewFrame* pViewFrm = GetViewFrame();
94 0 : SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
95 :
96 0 : SC_MOD()->SetRefDialog( nId, pWnd ? false : sal_True );
97 : }
98 : else
99 : {
100 :
101 : }
102 0 : }
103 :
104 0 : SfxModelessDialog* ScTabViewShell::CreateRefDialog(
105 : SfxBindings* pB, SfxChildWindow* pCW, SfxChildWinInfo* pInfo,
106 : Window* pParent, sal_uInt16 nSlotId )
107 : {
108 : // Dialog nur aufmachen, wenn ueber ScModule::SetRefDialog gerufen, damit
109 : // z.B. nach einem Absturz offene Ref-Dialoge nicht wiederkommen (#42341#).
110 :
111 0 : if ( SC_MOD()->GetCurRefDlgId() != nSlotId )
112 0 : return NULL;
113 :
114 0 : if ( nCurRefDlgId != nSlotId )
115 : {
116 : // the dialog has been opened in a different view
117 : // -> lock the dispatcher for this view (modal mode)
118 :
119 0 : GetViewData()->GetDispatcher().Lock( sal_True ); // lock is reset when closing dialog
120 0 : return NULL;
121 : }
122 :
123 0 : SfxModelessDialog* pResult = 0;
124 :
125 0 : if(pCW)
126 0 : pCW->SetHideNotDelete(sal_True);
127 :
128 0 : ScDocument* pDoc = GetViewData()->GetDocument();
129 :
130 0 : switch( nSlotId )
131 : {
132 : case FID_DEFINE_NAME:
133 : {
134 0 : if (!mbInSwitch)
135 : {
136 0 : pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(),
137 0 : ScAddress( GetViewData()->GetCurX(),
138 : GetViewData()->GetCurY(),
139 0 : GetViewData()->GetTabNo() ) );
140 : }
141 : else
142 : {
143 0 : pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(),
144 0 : ScAddress( GetViewData()->GetCurX(),
145 : GetViewData()->GetCurY(),
146 0 : GetViewData()->GetTabNo() ), &maRangeMap);
147 0 : static_cast<ScNameDlg*>(pResult)->SetEntry( maName, maScope);
148 0 : mbInSwitch = false;
149 : }
150 : }
151 0 : break;
152 :
153 : case FID_ADD_NAME:
154 : {
155 0 : if (!mbInSwitch)
156 : {
157 0 : std::map<OUString, ScRangeName*> aRangeMap;
158 0 : pDoc->GetRangeNameMap(aRangeMap);
159 0 : pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData(), aRangeMap,
160 0 : ScAddress( GetViewData()->GetCurX(),
161 : GetViewData()->GetCurY(),
162 0 : GetViewData()->GetTabNo() ), true );
163 : }
164 : else
165 : {
166 0 : std::map<OUString, ScRangeName*> aRangeMap;
167 0 : for (boost::ptr_map<OUString, ScRangeName>::iterator itr = maRangeMap.begin();
168 0 : itr != maRangeMap.end(); ++itr)
169 : {
170 0 : aRangeMap.insert(std::pair<OUString, ScRangeName*>(itr->first, itr->second));
171 : }
172 0 : pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData(), aRangeMap,
173 0 : ScAddress( GetViewData()->GetCurX(),
174 : GetViewData()->GetCurY(),
175 0 : GetViewData()->GetTabNo() ), false );
176 : }
177 : }
178 0 : break;
179 :
180 : case SID_DEFINE_COLROWNAMERANGES:
181 : {
182 0 : pResult = new ScColRowNameRangesDlg( pB, pCW, pParent, GetViewData() );
183 : }
184 0 : break;
185 :
186 : case SID_OPENDLG_CONSOLIDATE:
187 : {
188 0 : SfxItemSet aArgSet( GetPool(),
189 : SCITEM_CONSOLIDATEDATA,
190 0 : SCITEM_CONSOLIDATEDATA );
191 :
192 : const ScConsolidateParam* pDlgData =
193 0 : pDoc->GetConsolidateDlgData();
194 :
195 0 : if ( !pDlgData )
196 : {
197 0 : ScConsolidateParam aConsParam;
198 : SCCOL nStartCol, nEndCol;
199 : SCROW nStartRow, nEndRow;
200 : SCTAB nStartTab, nEndTab;
201 :
202 : GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab,
203 0 : nEndCol, nEndRow, nEndTab );
204 :
205 0 : PutInOrder( nStartCol, nEndCol );
206 0 : PutInOrder( nStartRow, nEndRow );
207 0 : PutInOrder( nStartTab, nEndTab );
208 :
209 0 : aConsParam.nCol = nStartCol;
210 0 : aConsParam.nRow = nStartRow;
211 0 : aConsParam.nTab = nStartTab;
212 :
213 : aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA,
214 0 : &aConsParam ) );
215 : }
216 : else
217 : {
218 0 : aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA, pDlgData ) );
219 : }
220 0 : pResult = new ScConsolidateDlg( pB, pCW, pParent, aArgSet );
221 : }
222 0 : break;
223 :
224 : case SID_DEFINE_DBNAME:
225 : {
226 : // wenn auf einem bestehenden Bereich aufgerufen, den markieren
227 0 : GetDBData( sal_True, SC_DB_OLD );
228 0 : const ScMarkData& rMark = GetViewData()->GetMarkData();
229 0 : if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
230 0 : MarkDataArea( false );
231 :
232 0 : pResult = new ScDbNameDlg( pB, pCW, pParent, GetViewData() );
233 : }
234 0 : break;
235 :
236 : case SID_SPECIAL_FILTER:
237 : {
238 0 : ScQueryParam aQueryParam;
239 0 : SfxItemSet aArgSet( GetPool(),
240 : SCITEM_QUERYDATA,
241 0 : SCITEM_QUERYDATA );
242 :
243 0 : ScDBData* pDBData = GetDBData(false, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
244 0 : pDBData->ExtendDataArea(pDoc);
245 0 : pDBData->GetQueryParam( aQueryParam );
246 :
247 0 : ScRange aArea;
248 0 : pDBData->GetArea(aArea);
249 0 : MarkRange(aArea, false);
250 :
251 0 : ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam );
252 0 : ScRange aAdvSource;
253 0 : if (pDBData->GetAdvancedQuerySource(aAdvSource))
254 0 : aItem.SetAdvancedQuerySource( &aAdvSource );
255 :
256 0 : aArgSet.Put( aItem );
257 :
258 : // aktuelle Tabelle merken (wg. RefInput im Dialog)
259 0 : GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
260 :
261 0 : pResult = new ScSpecialFilterDlg( pB, pCW, pParent, aArgSet );
262 : }
263 0 : break;
264 :
265 : case SID_FILTER:
266 : {
267 :
268 0 : ScQueryParam aQueryParam;
269 0 : SfxItemSet aArgSet( GetPool(),
270 : SCITEM_QUERYDATA,
271 0 : SCITEM_QUERYDATA );
272 :
273 0 : ScDBData* pDBData = GetDBData(false, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
274 0 : pDBData->ExtendDataArea(pDoc);
275 0 : pDBData->GetQueryParam( aQueryParam );
276 :
277 0 : ScRange aArea;
278 0 : pDBData->GetArea(aArea);
279 0 : MarkRange(aArea, false);
280 :
281 : aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA,
282 : GetViewData(),
283 0 : &aQueryParam ) );
284 :
285 : // aktuelle Tabelle merken (wg. RefInput im Dialog)
286 0 : GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
287 :
288 0 : pResult = new ScFilterDlg( pB, pCW, pParent, aArgSet );
289 : }
290 0 : break;
291 :
292 : case SID_OPENDLG_TABOP:
293 : {
294 0 : ScViewData* pViewData = GetViewData();
295 0 : ScRefAddress aCurPos ( pViewData->GetCurX(),
296 : pViewData->GetCurY(),
297 0 : pViewData->GetTabNo(),
298 0 : false, false, false );
299 :
300 0 : pResult = new ScTabOpDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos );
301 : }
302 0 : break;
303 :
304 : case SID_OPENDLG_SOLVE:
305 : {
306 0 : ScViewData* pViewData = GetViewData();
307 0 : ScAddress aCurPos( pViewData->GetCurX(),
308 : pViewData->GetCurY(),
309 0 : pViewData->GetTabNo());
310 0 : pResult = new ScSolverDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos );
311 : }
312 0 : break;
313 :
314 : case SID_OPENDLG_OPTSOLVER:
315 : {
316 0 : ScViewData* pViewData = GetViewData();
317 0 : ScAddress aCurPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
318 0 : pResult = new ScOptSolverDlg( pB, pCW, pParent, pViewData->GetDocShell(), aCurPos );
319 : }
320 0 : break;
321 :
322 : case SID_OPENDLG_PIVOTTABLE:
323 : {
324 : #if ! MPL_HAVE_SUBSET
325 : // all settings must be in pDialogDPObject
326 :
327 0 : if( pDialogDPObject )
328 : {
329 : // Check for an existing datapilot output.
330 0 : ScViewData* pViewData = GetViewData();
331 : ScDPObject* pObj = pDoc->GetDPAtCursor(
332 0 : pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
333 :
334 0 : GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
335 0 : pResult = new ScPivotLayoutDlg( pB, pCW, pParent, *pDialogDPObject, pObj == NULL);
336 : }
337 : #endif
338 : }
339 0 : break;
340 :
341 : case SID_OPENDLG_EDIT_PRINTAREA:
342 : {
343 0 : pResult = new ScPrintAreasDlg( pB, pCW, pParent );
344 : }
345 0 : break;
346 :
347 : case SID_OPENDLG_FUNCTION:
348 : {
349 : // Dialog schaut selber, was in der Zelle steht
350 :
351 0 : pResult = new ScFormulaDlg( pB, pCW, pParent, GetViewData(),ScGlobal::GetStarCalcFunctionMgr() );
352 : }
353 0 : break;
354 :
355 : case SID_MANAGE_XML_SOURCE:
356 : {
357 0 : pResult = new ScXMLSourceDlg(pB, pCW, pParent, pDoc);
358 : }
359 0 : break;
360 :
361 : case FID_CHG_SHOW:
362 : {
363 : // Dialog schaut selber, was in der Zelle steht
364 :
365 0 : pResult = new ScHighlightChgDlg( pB, pCW, pParent, GetViewData() );
366 : }
367 0 : break;
368 :
369 : case WID_SIMPLE_REF:
370 : {
371 : // Dialog schaut selber, was in der Zelle steht
372 :
373 0 : ScViewData* pViewData = GetViewData();
374 0 : pViewData->SetRefTabNo( pViewData->GetTabNo() );
375 0 : pResult = new ScSimpleRefDlg( pB, pCW, pParent, pViewData );
376 : }
377 0 : break;
378 :
379 :
380 : default:
381 : OSL_FAIL( "ScTabViewShell::CreateRefDialog: unbekannte ID" );
382 0 : break;
383 : }
384 :
385 0 : if (pResult)
386 : {
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 !!!)
390 :
391 0 : Size aSize = pResult->GetSizePixel();
392 0 : pResult->Initialize( pInfo );
393 0 : pResult->SetSizePixel(aSize);
394 : }
395 :
396 0 : return pResult;
397 93 : }
398 :
399 :
400 :
401 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|