merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / view / tabvwshc.cxx
blob200782e655574991dfb8d03cfc117b6affc8c2ef
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tabvwshc.cxx,v $
10 * $Revision: 1.13.32.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 //------------------------------------------------------------------
38 // INCLUDE ---------------------------------------------------------------
39 #include "scitems.hxx"
40 #include <vcl/msgbox.hxx>
41 #include <sfx2/childwin.hxx>
42 #include <sfx2/dispatch.hxx>
44 #include "tabvwsh.hxx"
45 #include "sc.hrc"
46 #include "globstr.hrc"
47 #include "global.hxx"
48 #include "scmod.hxx"
49 #include "docsh.hxx"
50 #include "document.hxx"
51 #include "uiitems.hxx"
52 #include "pivot.hxx"
53 #include "namedlg.hxx"
54 #include "solvrdlg.hxx"
55 #include "optsolver.hxx"
56 #include "tabopdlg.hxx"
57 #include "autoform.hxx" // Core
58 #include "autofmt.hxx" // Dialog
59 #include "consdlg.hxx"
60 //CHINA001 #include "sortdlg.hxx"
61 #include "filtdlg.hxx"
62 #include "dbnamdlg.hxx"
63 #include "pvlaydlg.hxx"
64 #include "areasdlg.hxx"
65 #include "condfrmt.hxx"
66 #include "rangeutl.hxx"
67 #include "crnrdlg.hxx"
68 #include "formula.hxx"
69 #include "cell.hxx" // Input Status Edit-Zellen
70 #include "acredlin.hxx"
71 #include "highred.hxx"
72 #include "simpref.hxx"
73 #include "funcdesc.hxx"
74 #include "dpobject.hxx"
76 //------------------------------------------------------------------
78 void ScTabViewShell::SetCurRefDlgId( USHORT nNew )
80 // CurRefDlgId is stored in ScModule to find if a ref dialog is open,
81 // and in the view to identify the view that has opened the dialog
82 nCurRefDlgId = nNew;
85 SfxModelessDialog* ScTabViewShell::CreateRefDialog(
86 SfxBindings* pB, SfxChildWindow* pCW, SfxChildWinInfo* pInfo,
87 Window* pParent, USHORT nSlotId )
89 // Dialog nur aufmachen, wenn ueber ScModule::SetRefDialog gerufen, damit
90 // z.B. nach einem Absturz offene Ref-Dialoge nicht wiederkommen (#42341#).
92 if ( SC_MOD()->GetCurRefDlgId() != nSlotId )
93 return NULL;
95 if ( nCurRefDlgId != nSlotId )
97 // the dialog has been opened in a different view
98 // -> lock the dispatcher for this view (modal mode)
100 GetViewData()->GetDispatcher().Lock( TRUE ); // lock is reset when closing dialog
101 return NULL;
104 SfxModelessDialog* pResult = 0;
106 if(pCW)
107 pCW->SetHideNotDelete(TRUE);
109 switch( nSlotId )
111 case FID_DEFINE_NAME:
112 pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(),
113 ScAddress( GetViewData()->GetCurX(),
114 GetViewData()->GetCurY(),
115 GetViewData()->GetTabNo() ) );
116 break;
118 case SID_DEFINE_COLROWNAMERANGES:
120 pResult = new ScColRowNameRangesDlg( pB, pCW, pParent, GetViewData() );
122 break;
124 case SID_OPENDLG_CONSOLIDATE:
126 SfxItemSet aArgSet( GetPool(),
127 SCITEM_CONSOLIDATEDATA,
128 SCITEM_CONSOLIDATEDATA );
130 const ScConsolidateParam* pDlgData =
131 GetViewData()->GetDocument()->GetConsolidateDlgData();
133 if ( !pDlgData )
135 ScConsolidateParam aConsParam;
136 SCCOL nStartCol, nEndCol;
137 SCROW nStartRow, nEndRow;
138 SCTAB nStartTab, nEndTab;
140 GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab,
141 nEndCol, nEndRow, nEndTab );
143 PutInOrder( nStartCol, nEndCol );
144 PutInOrder( nStartRow, nEndRow );
145 PutInOrder( nStartTab, nEndTab );
147 aConsParam.nCol = nStartCol;
148 aConsParam.nRow = nStartRow;
149 aConsParam.nTab = nStartTab;
151 aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA,
152 &aConsParam ) );
154 else
156 aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA, pDlgData ) );
158 pResult = new ScConsolidateDlg( pB, pCW, pParent, aArgSet );
160 break;
162 case SID_DEFINE_DBNAME:
164 // wenn auf einem bestehenden Bereich aufgerufen, den markieren
165 GetDBData( TRUE, SC_DB_OLD );
166 const ScMarkData& rMark = GetViewData()->GetMarkData();
167 if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
168 MarkDataArea( FALSE );
170 pResult = new ScDbNameDlg( pB, pCW, pParent, GetViewData() );
172 break;
174 case SID_SPECIAL_FILTER:
176 ScQueryParam aQueryParam;
177 SfxItemSet aArgSet( GetPool(),
178 SCITEM_QUERYDATA,
179 SCITEM_QUERYDATA );
181 ScDBData* pDBData = GetDBData(true, SC_DB_MAKE, true);
182 pDBData->GetQueryParam( aQueryParam );
183 aQueryParam.bUseDynamicRange = true;
185 ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam );
186 ScRange aAdvSource;
187 if (pDBData->GetAdvancedQuerySource(aAdvSource))
188 aItem.SetAdvancedQuerySource( &aAdvSource );
190 aArgSet.Put( aItem );
192 // aktuelle Tabelle merken (wg. RefInput im Dialog)
193 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
195 pResult = new ScSpecialFilterDlg( pB, pCW, pParent, aArgSet );
197 break;
199 case SID_FILTER:
202 ScQueryParam aQueryParam;
203 SfxItemSet aArgSet( GetPool(),
204 SCITEM_QUERYDATA,
205 SCITEM_QUERYDATA );
207 ScDBData* pDBData = GetDBData(true, SC_DB_MAKE, true);
208 pDBData->GetQueryParam( aQueryParam );
209 aQueryParam.bUseDynamicRange = true;
211 aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA,
212 GetViewData(),
213 &aQueryParam ) );
215 // aktuelle Tabelle merken (wg. RefInput im Dialog)
216 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
218 pResult = new ScFilterDlg( pB, pCW, pParent, aArgSet );
220 break;
222 case SID_OPENDLG_TABOP:
224 ScViewData* pViewData = GetViewData();
225 ScRefAddress aCurPos ( pViewData->GetCurX(),
226 pViewData->GetCurY(),
227 pViewData->GetTabNo(),
228 FALSE, FALSE, FALSE );
230 pResult = new ScTabOpDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos );
232 break;
234 case SID_OPENDLG_SOLVE:
236 ScViewData* pViewData = GetViewData();
237 ScAddress aCurPos( pViewData->GetCurX(),
238 pViewData->GetCurY(),
239 pViewData->GetTabNo());
240 pResult = new ScSolverDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos );
242 break;
244 case SID_OPENDLG_OPTSOLVER:
246 ScViewData* pViewData = GetViewData();
247 ScAddress aCurPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
248 pResult = new ScOptSolverDlg( pB, pCW, pParent, pViewData->GetDocShell(), aCurPos );
250 break;
252 case SID_OPENDLG_PIVOTTABLE:
254 // all settings must be in pDialogDPObject
256 if( pDialogDPObject )
258 // Check for an existing datapilot output.
259 ScViewData* pViewData = GetViewData();
260 ScDPObject* pObj = GetViewData()->GetDocument()->GetDPAtCursor(
261 pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
263 GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
264 pResult = new ScDPLayoutDlg( pB, pCW, pParent, *pDialogDPObject, pObj == NULL);
267 break;
269 case SID_OPENDLG_EDIT_PRINTAREA:
271 pResult = new ScPrintAreasDlg( pB, pCW, pParent );
273 break;
275 case SID_OPENDLG_CONDFRMT:
277 ScViewData* pViewData = GetViewData();
279 ScDocument* pDoc = pViewData->GetDocument();
280 const ScConditionalFormat* pForm = pDoc->GetCondFormat(
281 pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() );
283 // aktuelle Tabelle merken (wg. RefInput im Dialog)
284 pViewData->SetRefTabNo( pViewData->GetTabNo() );
286 pResult = new ScConditionalFormatDlg( pB, pCW, pParent, pDoc, pForm );
288 break;
290 case SID_OPENDLG_FUNCTION:
292 // Dialog schaut selber, was in der Zelle steht
294 pResult = new ScFormulaDlg( pB, pCW, pParent, GetViewData(),ScGlobal::GetStarCalcFunctionMgr() );
296 break;
298 case FID_CHG_SHOW:
300 // Dialog schaut selber, was in der Zelle steht
302 pResult = new ScHighlightChgDlg( pB, pCW, pParent, GetViewData() );
304 break;
306 case WID_SIMPLE_REF:
308 // Dialog schaut selber, was in der Zelle steht
310 ScViewData* pViewData = GetViewData();
311 pViewData->SetRefTabNo( pViewData->GetTabNo() );
312 pResult = new ScSimpleRefDlg( pB, pCW, pParent, pViewData );
314 break;
317 default:
318 DBG_ERROR( "ScTabViewShell::CreateRefDialog: unbekannte ID" );
319 break;
322 if (pResult)
324 // Die Dialoge gehen immer mit eingeklapptem Zusaetze-Button auf,
325 // darum muss die Groesse ueber das Initialize gerettet werden
326 // (oder den Zusaetze-Status mit speichern !!!)
328 Size aSize = pResult->GetSizePixel();
329 pResult->Initialize( pInfo );
330 pResult->SetSizePixel(aSize);
333 return pResult;