LCOV - code coverage report
Current view: top level - sc/source/ui/view - tabvwshc.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 168 0.0 %
Date: 2014-04-14 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          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"
      42             : #include "autofmt.hxx"
      43             : #include "consdlg.hxx"
      44             : #include "filtdlg.hxx"
      45             : #include "dbnamdlg.hxx"
      46             : #include "areasdlg.hxx"
      47             : #include "rangeutl.hxx"
      48             : #include "crnrdlg.hxx"
      49             : #include "formula.hxx"
      50             : #include "formulacell.hxx"
      51             : #include "acredlin.hxx"
      52             : #include "highred.hxx"
      53             : #include "simpref.hxx"
      54             : #include "funcdesc.hxx"
      55             : #include "dpobject.hxx"
      56             : #include "markdata.hxx"
      57             : #include "reffact.hxx"
      58             : #include "condformatdlg.hxx"
      59             : #include "xmlsourcedlg.hxx"
      60             : 
      61             : #include "RandomNumberGeneratorDialog.hxx"
      62             : #include "SamplingDialog.hxx"
      63             : #include "DescriptiveStatisticsDialog.hxx"
      64             : #include "AnalysisOfVarianceDialog.hxx"
      65             : #include "CorrelationDialog.hxx"
      66             : #include "CovarianceDialog.hxx"
      67             : #include "ExponentialSmoothingDialog.hxx"
      68             : #include "MovingAverageDialog.hxx"
      69             : #include "TTestDialog.hxx"
      70             : 
      71             : #include "PivotLayoutDialog.hxx"
      72             : 
      73             : #include <config_orcus.h>
      74             : 
      75           0 : 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           0 :     nCurRefDlgId = nNew;
      80           0 : }
      81             : 
      82             : //ugly hack to call Define Name from Manage Names
      83           0 : void ScTabViewShell::SwitchBetweenRefDialogs(SfxModelessDialog* pDialog)
      84             : {
      85           0 :    sal_uInt16 nSlotId = SC_MOD()->GetCurRefDlgId();
      86           0 :    if (nSlotId == FID_DEFINE_NAME)
      87             :    {
      88           0 :         mbInSwitch = true;
      89           0 :         static_cast<ScNameDlg*>(pDialog)->GetRangeNames(maRangeMap);
      90           0 :         static_cast<ScNameDlg*>(pDialog)->Close();
      91           0 :         sal_uInt16 nId  = ScNameDefDlgWrapper::GetChildWindowId();
      92           0 :         SfxViewFrame* pViewFrm = GetViewFrame();
      93           0 :         SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
      94             : 
      95           0 :         SC_MOD()->SetRefDialog( nId, pWnd ? false : sal_True );
      96             :    }
      97           0 :    else if( nSlotId == FID_ADD_NAME )
      98             :    {
      99           0 :         static_cast<ScNameDefDlg*>(pDialog)->GetNewData(maName, maScope);
     100           0 :         static_cast<ScNameDlg*>(pDialog)->Close();
     101           0 :         sal_uInt16 nId  = ScNameDlgWrapper::GetChildWindowId();
     102           0 :         SfxViewFrame* pViewFrm = GetViewFrame();
     103           0 :         SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
     104             : 
     105           0 :         SC_MOD()->SetRefDialog( nId, pWnd ? false : sal_True );
     106             :    }
     107             :    else
     108             :    {
     109             : 
     110             :    }
     111           0 : }
     112             : 
     113           0 : SfxModelessDialog* ScTabViewShell::CreateRefDialog(
     114             :                         SfxBindings* pB, SfxChildWindow* pCW, SfxChildWinInfo* pInfo,
     115             :                         Window* pParent, sal_uInt16 nSlotId )
     116             : {
     117             :     //  Dialog nur aufmachen, wenn ueber ScModule::SetRefDialog gerufen, damit
     118             :     //  z.B. nach einem Absturz offene Ref-Dialoge nicht wiederkommen (#42341#).
     119             : 
     120           0 :     if ( SC_MOD()->GetCurRefDlgId() != nSlotId )
     121           0 :         return NULL;
     122             : 
     123           0 :     if ( nCurRefDlgId != nSlotId )
     124             :     {
     125             :         //  the dialog has been opened in a different view
     126             :         //  -> lock the dispatcher for this view (modal mode)
     127             : 
     128           0 :         GetViewData()->GetDispatcher().Lock( true );    // lock is reset when closing dialog
     129           0 :         return NULL;
     130             :     }
     131             : 
     132           0 :     SfxModelessDialog* pResult = 0;
     133             : 
     134           0 :     if(pCW)
     135           0 :         pCW->SetHideNotDelete(true);
     136             : 
     137           0 :     ScDocument* pDoc = GetViewData()->GetDocument();
     138             : 
     139           0 :     switch( nSlotId )
     140             :     {
     141             :         case FID_DEFINE_NAME:
     142             :         {
     143           0 :             if (!mbInSwitch)
     144             :             {
     145           0 :                 pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(),
     146           0 :                                      ScAddress( GetViewData()->GetCurX(),
     147             :                                                 GetViewData()->GetCurY(),
     148           0 :                                                 GetViewData()->GetTabNo() ) );
     149             :             }
     150             :             else
     151             :             {
     152           0 :                 pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(),
     153           0 :                                      ScAddress( GetViewData()->GetCurX(),
     154             :                                                 GetViewData()->GetCurY(),
     155           0 :                                                 GetViewData()->GetTabNo() ), &maRangeMap);
     156           0 :                 static_cast<ScNameDlg*>(pResult)->SetEntry( maName, maScope);
     157           0 :                 mbInSwitch = false;
     158             :             }
     159             :         }
     160           0 :         break;
     161             : 
     162             :         case FID_ADD_NAME:
     163             :         {
     164           0 :             if (!mbInSwitch)
     165             :             {
     166           0 :                 std::map<OUString, ScRangeName*> aRangeMap;
     167           0 :                 pDoc->GetRangeNameMap(aRangeMap);
     168           0 :                 pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData(), aRangeMap,
     169           0 :                                 ScAddress( GetViewData()->GetCurX(),
     170             :                                             GetViewData()->GetCurY(),
     171           0 :                                             GetViewData()->GetTabNo() ), true );
     172             :             }
     173             :             else
     174             :             {
     175           0 :                 std::map<OUString, ScRangeName*> aRangeMap;
     176           0 :                 for (boost::ptr_map<OUString, ScRangeName>::iterator itr = maRangeMap.begin();
     177           0 :                         itr != maRangeMap.end(); ++itr)
     178             :                 {
     179           0 :                     aRangeMap.insert(std::pair<OUString, ScRangeName*>(itr->first, itr->second));
     180             :                 }
     181           0 :                 pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData(), aRangeMap,
     182           0 :                                 ScAddress( GetViewData()->GetCurX(),
     183             :                                             GetViewData()->GetCurY(),
     184           0 :                                             GetViewData()->GetTabNo() ), false );
     185             :             }
     186             :         }
     187           0 :         break;
     188             : 
     189             :         case SID_DEFINE_COLROWNAMERANGES:
     190             :         {
     191           0 :             pResult = new ScColRowNameRangesDlg( pB, pCW, pParent, GetViewData() );
     192             :         }
     193           0 :         break;
     194             : 
     195             :         case SID_OPENDLG_CONSOLIDATE:
     196             :         {
     197           0 :             SfxItemSet aArgSet( GetPool(),
     198             :                                 SCITEM_CONSOLIDATEDATA,
     199           0 :                                 SCITEM_CONSOLIDATEDATA );
     200             : 
     201             :             const ScConsolidateParam* pDlgData =
     202           0 :                             pDoc->GetConsolidateDlgData();
     203             : 
     204           0 :             if ( !pDlgData )
     205             :             {
     206           0 :                 ScConsolidateParam  aConsParam;
     207             :                 SCCOL nStartCol, nEndCol;
     208             :                 SCROW nStartRow, nEndRow;
     209             :                 SCTAB nStartTab, nEndTab;
     210             : 
     211             :                 GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab,
     212           0 :                                               nEndCol,   nEndRow,   nEndTab );
     213             : 
     214           0 :                 PutInOrder( nStartCol, nEndCol );
     215           0 :                 PutInOrder( nStartRow, nEndRow );
     216           0 :                 PutInOrder( nStartTab, nEndTab );
     217             : 
     218           0 :                 aConsParam.nCol = nStartCol;
     219           0 :                 aConsParam.nRow = nStartRow;
     220           0 :                 aConsParam.nTab = nStartTab;
     221             : 
     222             :                 aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA,
     223           0 :                                                 &aConsParam ) );
     224             :             }
     225             :             else
     226             :             {
     227           0 :                 aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA, pDlgData ) );
     228             :             }
     229           0 :             pResult = new ScConsolidateDlg( pB, pCW, pParent, aArgSet );
     230             :         }
     231           0 :         break;
     232             : 
     233             :         case SID_DEFINE_DBNAME:
     234             :         {
     235             :             //  wenn auf einem bestehenden Bereich aufgerufen, den markieren
     236           0 :             GetDBData( true, SC_DB_OLD );
     237           0 :             const ScMarkData& rMark = GetViewData()->GetMarkData();
     238           0 :             if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
     239           0 :                 MarkDataArea( false );
     240             : 
     241           0 :             pResult = new ScDbNameDlg( pB, pCW, pParent, GetViewData() );
     242             :         }
     243           0 :         break;
     244             : 
     245             :         case SID_SPECIAL_FILTER:
     246             :         {
     247           0 :             ScQueryParam    aQueryParam;
     248           0 :             SfxItemSet      aArgSet( GetPool(),
     249             :                                      SCITEM_QUERYDATA,
     250           0 :                                      SCITEM_QUERYDATA );
     251             : 
     252           0 :             ScDBData* pDBData = GetDBData(false, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
     253           0 :             pDBData->ExtendDataArea(pDoc);
     254           0 :             pDBData->GetQueryParam( aQueryParam );
     255             : 
     256           0 :             ScRange aArea;
     257           0 :             pDBData->GetArea(aArea);
     258           0 :             MarkRange(aArea, false);
     259             : 
     260           0 :             ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam );
     261           0 :             ScRange aAdvSource;
     262           0 :             if (pDBData->GetAdvancedQuerySource(aAdvSource))
     263           0 :                 aItem.SetAdvancedQuerySource( &aAdvSource );
     264             : 
     265           0 :             aArgSet.Put( aItem );
     266             : 
     267             :             // aktuelle Tabelle merken (wg. RefInput im Dialog)
     268           0 :             GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
     269             : 
     270           0 :             pResult = new ScSpecialFilterDlg( pB, pCW, pParent, aArgSet );
     271             :         }
     272           0 :         break;
     273             : 
     274             :         case SID_FILTER:
     275             :         {
     276             : 
     277           0 :             ScQueryParam    aQueryParam;
     278           0 :             SfxItemSet      aArgSet( GetPool(),
     279             :                                      SCITEM_QUERYDATA,
     280           0 :                                      SCITEM_QUERYDATA );
     281             : 
     282           0 :             ScDBData* pDBData = GetDBData(false, SC_DB_MAKE, SC_DBSEL_ROW_DOWN);
     283           0 :             pDBData->ExtendDataArea(pDoc);
     284           0 :             pDBData->GetQueryParam( aQueryParam );
     285             : 
     286           0 :             ScRange aArea;
     287           0 :             pDBData->GetArea(aArea);
     288           0 :             MarkRange(aArea, false);
     289             : 
     290             :             aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA,
     291             :                                       GetViewData(),
     292           0 :                                       &aQueryParam ) );
     293             : 
     294             :             // aktuelle Tabelle merken (wg. RefInput im Dialog)
     295           0 :             GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
     296             : 
     297           0 :             pResult = new ScFilterDlg( pB, pCW, pParent, aArgSet );
     298             :         }
     299           0 :         break;
     300             : 
     301             :         case SID_OPENDLG_TABOP:
     302             :         {
     303           0 :             ScViewData*  pViewData  = GetViewData();
     304           0 :             ScRefAddress  aCurPos   ( pViewData->GetCurX(),
     305             :                                       pViewData->GetCurY(),
     306           0 :                                       pViewData->GetTabNo(),
     307           0 :                                       false, false, false );
     308             : 
     309           0 :             pResult = new ScTabOpDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos );
     310             :         }
     311           0 :         break;
     312             : 
     313             :         case SID_OPENDLG_SOLVE:
     314             :         {
     315           0 :             ScViewData*  pViewData  = GetViewData();
     316           0 :             ScAddress aCurPos(  pViewData->GetCurX(),
     317             :                                 pViewData->GetCurY(),
     318           0 :                                 pViewData->GetTabNo());
     319           0 :             pResult = new ScSolverDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos );
     320             :         }
     321           0 :         break;
     322             : 
     323             :         case SID_RANDOM_NUMBER_GENERATOR_DIALOG:
     324             :         {
     325           0 :             pResult = new ScRandomNumberGeneratorDialog( pB, pCW, pParent, GetViewData() );
     326             :         }
     327           0 :         break;
     328             : 
     329             :         case SID_SAMPLING_DIALOG:
     330             :         {
     331           0 :             pResult = new ScSamplingDialog( pB, pCW, pParent, GetViewData() );
     332             :         }
     333           0 :         break;
     334             : 
     335             :         case SID_DESCRIPTIVE_STATISTICS_DIALOG:
     336             :         {
     337           0 :             pResult = new ScDescriptiveStatisticsDialog( pB, pCW, pParent, GetViewData() );
     338             :         }
     339           0 :         break;
     340             : 
     341             :         case SID_ANALYSIS_OF_VARIANCE_DIALOG:
     342             :         {
     343           0 :             pResult = new ScAnalysisOfVarianceDialog( pB, pCW, pParent, GetViewData() );
     344             :         }
     345           0 :         break;
     346             : 
     347             :         case SID_CORRELATION_DIALOG:
     348             :         {
     349           0 :             pResult = new ScCorrelationDialog( pB, pCW, pParent, GetViewData() );
     350             :         }
     351           0 :         break;
     352             : 
     353             :         case SID_COVARIANCE_DIALOG:
     354             :         {
     355           0 :             pResult = new ScCovarianceDialog( pB, pCW, pParent, GetViewData() );
     356             :         }
     357           0 :         break;
     358             : 
     359             :         case SID_EXPONENTIAL_SMOOTHING_DIALOG:
     360             :         {
     361           0 :             pResult = new ScExponentialSmoothingDialog( pB, pCW, pParent, GetViewData() );
     362             :         }
     363           0 :         break;
     364             : 
     365             :         case SID_MOVING_AVERAGE_DIALOG:
     366             :         {
     367           0 :             pResult = new ScMovingAverageDialog( pB, pCW, pParent, GetViewData() );
     368             :         }
     369           0 :         break;
     370             : 
     371             :         case SID_TTEST_DIALOG:
     372             :         {
     373           0 :             pResult = new ScTTestDialog( pB, pCW, pParent, GetViewData() );
     374             :         }
     375           0 :         break;
     376             : 
     377             :         case SID_OPENDLG_OPTSOLVER:
     378             :         {
     379           0 :             ScViewData* pViewData = GetViewData();
     380           0 :             ScAddress aCurPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
     381           0 :             pResult = new ScOptSolverDlg( pB, pCW, pParent, pViewData->GetDocShell(), aCurPos );
     382             :         }
     383           0 :         break;
     384             : 
     385             :         case SID_OPENDLG_PIVOTTABLE:
     386             :         {
     387             :             //  all settings must be in pDialogDPObject
     388             : 
     389           0 :             if( pDialogDPObject )
     390             :             {
     391             :                 // Check for an existing datapilot output.
     392           0 :                 ScViewData* pViewData = GetViewData();
     393           0 :                 pViewData->SetRefTabNo( pViewData->GetTabNo() );
     394           0 :                 ScDPObject* pObj = pDoc->GetDPAtCursor(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
     395           0 :                 pResult = new ScPivotLayoutDialog(pB, pCW, pParent, pViewData, pDialogDPObject, pObj == NULL);
     396             :             }
     397             :         }
     398           0 :         break;
     399             : 
     400             :         case SID_OPENDLG_EDIT_PRINTAREA:
     401             :         {
     402           0 :             pResult = new ScPrintAreasDlg( pB, pCW, pParent );
     403             :         }
     404           0 :         break;
     405             : 
     406             :         case SID_OPENDLG_FUNCTION:
     407             :         {
     408             :             //  Dialog schaut selber, was in der Zelle steht
     409             : 
     410           0 :             pResult = new ScFormulaDlg( pB, pCW, pParent, GetViewData(),ScGlobal::GetStarCalcFunctionMgr() );
     411             :         }
     412           0 :         break;
     413             : 
     414             :         case SID_MANAGE_XML_SOURCE:
     415             :         {
     416             : #if ENABLE_ORCUS
     417           0 :             pResult = new ScXMLSourceDlg(pB, pCW, pParent, pDoc);
     418             : #endif
     419             :         }
     420           0 :         break;
     421             : 
     422             :         case FID_CHG_SHOW:
     423             :         {
     424             :             //  Dialog schaut selber, was in der Zelle steht
     425             : 
     426           0 :             pResult = new ScHighlightChgDlg( pB, pCW, pParent, GetViewData() );
     427             :         }
     428           0 :         break;
     429             : 
     430             :         case WID_SIMPLE_REF:
     431             :         {
     432             :             //  Dialog schaut selber, was in der Zelle steht
     433             : 
     434           0 :             ScViewData* pViewData = GetViewData();
     435           0 :             pViewData->SetRefTabNo( pViewData->GetTabNo() );
     436           0 :             pResult = new ScSimpleRefDlg( pB, pCW, pParent, pViewData );
     437             :         }
     438           0 :         break;
     439             : 
     440             : 
     441             :         default:
     442             :         OSL_FAIL( "ScTabViewShell::CreateRefDialog: unbekannte ID" );
     443           0 :         break;
     444             :     }
     445             : 
     446           0 :     if (pResult)
     447             :     {
     448             :         //  Die Dialoge gehen immer mit eingeklapptem Zusaetze-Button auf,
     449             :         //  darum muss die Groesse ueber das Initialize gerettet werden
     450             :         //  (oder den Zusaetze-Status mit speichern !!!)
     451             : 
     452           0 :         Size aSize = pResult->GetSizePixel();
     453           0 :         pResult->Initialize( pInfo );
     454           0 :         pResult->SetSizePixel(aSize);
     455             :     }
     456             : 
     457           0 :     return pResult;
     458           0 : }
     459             : 
     460             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10