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