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