xref: /aoo41x/main/sc/source/ui/view/tabvwshc.cxx (revision 22407013)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 
29 //------------------------------------------------------------------
30 
31 // INCLUDE ---------------------------------------------------------------
32 #include "scitems.hxx"
33 #include <vcl/msgbox.hxx>
34 #include <sfx2/childwin.hxx>
35 #include <sfx2/dispatch.hxx>
36 
37 #include "tabvwsh.hxx"
38 #include "sc.hrc"
39 #include "globstr.hrc"
40 #include "global.hxx"
41 #include "scmod.hxx"
42 #include "docsh.hxx"
43 #include "document.hxx"
44 #include "uiitems.hxx"
45 #include "pivot.hxx"
46 #include "namedlg.hxx"
47 #include "solvrdlg.hxx"
48 #include "optsolver.hxx"
49 #include "tabopdlg.hxx"
50 #include "autoform.hxx"         // Core
51 #include "autofmt.hxx"          // Dialog
52 #include "consdlg.hxx"
53 //CHINA001 #include "sortdlg.hxx"
54 #include "filtdlg.hxx"
55 #include "dbnamdlg.hxx"
56 #include "pvlaydlg.hxx"
57 #include "areasdlg.hxx"
58 #include "condfrmt.hxx"
59 #include "rangeutl.hxx"
60 #include "crnrdlg.hxx"
61 #include "formula.hxx"
62 #include "cell.hxx"             // Input Status Edit-Zellen
63 #include "acredlin.hxx"
64 #include "highred.hxx"
65 #include "simpref.hxx"
66 #include "funcdesc.hxx"
67 #include "dpobject.hxx"
68 
69 //------------------------------------------------------------------
70 
SetCurRefDlgId(sal_uInt16 nNew)71 void ScTabViewShell::SetCurRefDlgId( sal_uInt16 nNew )
72 {
73 	//	CurRefDlgId is stored in ScModule to find if a ref dialog is open,
74 	//	and in the view to identify the view that has opened the dialog
75 	nCurRefDlgId = nNew;
76 }
77 
CreateRefDialog(SfxBindings * pB,SfxChildWindow * pCW,SfxChildWinInfo * pInfo,Window * pParent,sal_uInt16 nSlotId)78 SfxModelessDialog* ScTabViewShell::CreateRefDialog(
79 						SfxBindings* pB, SfxChildWindow* pCW, SfxChildWinInfo* pInfo,
80 						Window* pParent, sal_uInt16 nSlotId )
81 {
82 	//	Dialog nur aufmachen, wenn ueber ScModule::SetRefDialog gerufen, damit
83 	//	z.B. nach einem Absturz offene Ref-Dialoge nicht wiederkommen (#42341#).
84 
85 	if ( SC_MOD()->GetCurRefDlgId() != nSlotId )
86 		return NULL;
87 
88 	if ( nCurRefDlgId != nSlotId )
89 	{
90 		//	the dialog has been opened in a different view
91 		//	-> lock the dispatcher for this view (modal mode)
92 
93 		GetViewData()->GetDispatcher().Lock( sal_True );	// lock is reset when closing dialog
94 		return NULL;
95 	}
96 
97 	SfxModelessDialog* pResult = 0;
98 
99 	if(pCW)
100 		pCW->SetHideNotDelete(sal_True);
101 
102 	switch( nSlotId )
103 	{
104 		case FID_DEFINE_NAME:
105 		pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(),
106 								 ScAddress( GetViewData()->GetCurX(),
107 											GetViewData()->GetCurY(),
108 											GetViewData()->GetTabNo() ) );
109 		break;
110 
111 		case SID_DEFINE_COLROWNAMERANGES:
112 		{
113 			pResult = new ScColRowNameRangesDlg( pB, pCW, pParent, GetViewData() );
114 		}
115 		break;
116 
117 		case SID_OPENDLG_CONSOLIDATE:
118 		{
119 			SfxItemSet aArgSet( GetPool(),
120 								SCITEM_CONSOLIDATEDATA,
121 								SCITEM_CONSOLIDATEDATA );
122 
123 			const ScConsolidateParam* pDlgData =
124 							GetViewData()->GetDocument()->GetConsolidateDlgData();
125 
126 			if ( !pDlgData )
127 			{
128 				ScConsolidateParam	aConsParam;
129                 SCCOL nStartCol, nEndCol;
130                 SCROW nStartRow, nEndRow;
131                 SCTAB nStartTab, nEndTab;
132 
133 				GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab,
134 											  nEndCol,	 nEndRow,	nEndTab );
135 
136 				PutInOrder( nStartCol, nEndCol );
137 				PutInOrder( nStartRow, nEndRow );
138 				PutInOrder( nStartTab, nEndTab );
139 
140 				aConsParam.nCol = nStartCol;
141 				aConsParam.nRow = nStartRow;
142 				aConsParam.nTab = nStartTab;
143 
144 				aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA,
145 												&aConsParam ) );
146 			}
147 			else
148 			{
149 				aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA, pDlgData ) );
150 			}
151 			pResult = new ScConsolidateDlg( pB, pCW, pParent, aArgSet );
152 		}
153 		break;
154 
155 		case SID_DEFINE_DBNAME:
156 		{
157 			//	wenn auf einem bestehenden Bereich aufgerufen, den markieren
158 			GetDBData( sal_True, SC_DB_OLD );
159 			const ScMarkData& rMark = GetViewData()->GetMarkData();
160 			if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
161 				MarkDataArea( sal_False );
162 
163 			pResult = new ScDbNameDlg( pB, pCW, pParent, GetViewData() );
164 		}
165 		break;
166 
167 		case SID_SPECIAL_FILTER:
168 		{
169 			ScQueryParam	aQueryParam;
170 			SfxItemSet		aArgSet( GetPool(),
171 									 SCITEM_QUERYDATA,
172 									 SCITEM_QUERYDATA );
173 
174 			ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
175 			pDBData->GetQueryParam( aQueryParam );
176 
177 			ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam );
178 			ScRange aAdvSource;
179 			if (pDBData->GetAdvancedQuerySource(aAdvSource))
180 				aItem.SetAdvancedQuerySource( &aAdvSource );
181 
182 			aArgSet.Put( aItem );
183 
184 			// aktuelle Tabelle merken (wg. RefInput im Dialog)
185 			GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
186 
187 			pResult = new ScSpecialFilterDlg( pB, pCW, pParent, aArgSet );
188 		}
189 		break;
190 
191 		case SID_FILTER:
192 		{
193 
194 			ScQueryParam	aQueryParam;
195 			SfxItemSet		aArgSet( GetPool(),
196 									 SCITEM_QUERYDATA,
197 									 SCITEM_QUERYDATA );
198 
199 			ScDBData* pDBData = GetDBData( sal_True, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
200 			pDBData->GetQueryParam( aQueryParam );
201 
202 			aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA,
203 									  GetViewData(),
204 									  &aQueryParam ) );
205 
206 			// aktuelle Tabelle merken (wg. RefInput im Dialog)
207 			GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
208 
209 			pResult = new ScFilterDlg( pB, pCW, pParent, aArgSet );
210 		}
211 		break;
212 
213 		case SID_OPENDLG_TABOP:
214 		{
215 			ScViewData*  pViewData	= GetViewData();
216 			ScRefAddress  aCurPos	( pViewData->GetCurX(),
217 									  pViewData->GetCurY(),
218 									  pViewData->GetTabNo(),
219 									  sal_False, sal_False, sal_False );
220 
221 			pResult = new ScTabOpDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos );
222 		}
223 		break;
224 
225 		case SID_OPENDLG_SOLVE:
226 		{
227 			ScViewData*  pViewData	= GetViewData();
228             ScAddress aCurPos(  pViewData->GetCurX(),
229                                 pViewData->GetCurY(),
230                                 pViewData->GetTabNo());
231 			pResult = new ScSolverDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos );
232 		}
233 		break;
234 
235         case SID_OPENDLG_OPTSOLVER:
236         {
237             ScViewData* pViewData = GetViewData();
238             ScAddress aCurPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
239             pResult = new ScOptSolverDlg( pB, pCW, pParent, pViewData->GetDocShell(), aCurPos );
240         }
241         break;
242 
243 		case SID_OPENDLG_PIVOTTABLE:
244 		{
245 			//	all settings must be in pDialogDPObject
246 
247             if( pDialogDPObject )
248             {
249                 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
250                 pResult = new ScPivotLayoutDlg( pB, pCW, pParent, *pDialogDPObject );
251             }
252 		}
253 		break;
254 
255 		case SID_OPENDLG_EDIT_PRINTAREA:
256 		{
257 			pResult = new ScPrintAreasDlg( pB, pCW, pParent );
258 		}
259 		break;
260 
261 		case SID_OPENDLG_CONDFRMT:
262 		{
263 			ScViewData* pViewData = GetViewData();
264 
265 			ScDocument* pDoc = pViewData->GetDocument();
266 			const ScConditionalFormat* pForm = pDoc->GetCondFormat(
267 				pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() );
268 
269 			// aktuelle Tabelle merken (wg. RefInput im Dialog)
270 			pViewData->SetRefTabNo( pViewData->GetTabNo() );
271 
272 			pResult = new ScConditionalFormatDlg( pB, pCW, pParent, pDoc, pForm );
273 		}
274 		break;
275 
276 		case SID_OPENDLG_FUNCTION:
277 		{
278 			//	Dialog schaut selber, was in der Zelle steht
279 
280 			pResult = new ScFormulaDlg( pB, pCW, pParent, GetViewData(),ScGlobal::GetStarCalcFunctionMgr() );
281 		}
282 		break;
283 
284 		case FID_CHG_SHOW:
285 		{
286 			//	Dialog schaut selber, was in der Zelle steht
287 
288 			pResult = new ScHighlightChgDlg( pB, pCW, pParent, GetViewData() );
289 		}
290 		break;
291 
292 		case WID_SIMPLE_REF:
293 		{
294 			//	Dialog schaut selber, was in der Zelle steht
295 
296             ScViewData* pViewData = GetViewData();
297             pViewData->SetRefTabNo( pViewData->GetTabNo() );
298             pResult = new ScSimpleRefDlg( pB, pCW, pParent, pViewData );
299 		}
300 		break;
301 
302 
303 		default:
304 		DBG_ERROR( "ScTabViewShell::CreateRefDialog: unbekannte ID" );
305 		break;
306 	}
307 
308 	if (pResult)
309 	{
310 		//	Die Dialoge gehen immer mit eingeklapptem Zusaetze-Button auf,
311 		//	darum muss die Groesse ueber das Initialize gerettet werden
312 		//	(oder den Zusaetze-Status mit speichern !!!)
313 
314 		Size aSize = pResult->GetSizePixel();
315 		pResult->Initialize( pInfo );
316 		pResult->SetSizePixel(aSize);
317 	}
318 
319 	return pResult;
320 }
321 
322 
323 
324