LCOV - code coverage report
Current view: top level - sc/source/ui/dbgui - consdlg.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 305 0.3 %
Date: 2014-11-03 Functions: 2 27 7.4 %
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 <sfx2/dispatch.hxx>
      21             : 
      22             : #include "tabvwsh.hxx"
      23             : #include "uiitems.hxx"
      24             : #include "dbdata.hxx"
      25             : #include "rangenam.hxx"
      26             : #include "rangeutl.hxx"
      27             : #include "reffact.hxx"
      28             : #include "document.hxx"
      29             : #include "scresid.hxx"
      30             : 
      31             : #include "globstr.hrc"
      32             : #include "sc.hrc"
      33             : 
      34             : #include "consdlg.hxx"
      35             : #include <vcl/msgbox.hxx>
      36             : 
      37             : #define INFOBOX(id) InfoBox(this, ScGlobal::GetRscString(id)).Execute()
      38             : 
      39             : class ScAreaData
      40             : {
      41             : public:
      42           0 :     ScAreaData()
      43           0 :         : bIsDbArea(false)
      44             :     {
      45           0 :     }
      46             : 
      47           0 :     ~ScAreaData() {}
      48             : 
      49           0 :     void Set( const OUString& rName, const OUString& rArea, bool bDb )
      50             :                 {
      51           0 :                     aStrName  = rName;
      52           0 :                     aStrArea  = rArea;
      53           0 :                     bIsDbArea = bDb;
      54           0 :                 }
      55             : 
      56             :     OUString  aStrName;
      57             :     OUString  aStrArea;
      58             :     bool  bIsDbArea;
      59             : };
      60             : 
      61           0 : ScConsolidateDlg::ScConsolidateDlg( SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent,
      62             :                                     const SfxItemSet&   rArgSet )
      63             : 
      64             :     :   ScAnyRefDlg ( pB, pCW, pParent, "ConsolidateDialog" , "modules/scalc/ui/consolidatedialog.ui" ),
      65             :         aStrUndefined   ( ScResId( SCSTR_UNDEFINED ) ),
      66             :         theConsData     ( static_cast<const ScConsolidateItem&>(
      67             :                            rArgSet.Get( rArgSet.GetPool()->
      68           0 :                                             GetWhich( SID_CONSOLIDATE ) )
      69           0 :                                       ).GetData() ),
      70           0 :         rViewData       ( static_cast<ScTabViewShell*>(SfxViewShell::Current())->
      71           0 :                                 GetViewData() ),
      72           0 :         pDoc            ( static_cast<ScTabViewShell*>(SfxViewShell::Current())->
      73           0 :                                 GetViewData().GetDocument() ),
      74           0 :         pRangeUtil      ( new ScRangeUtil ),
      75             :         pAreaData       ( NULL ),
      76             :         nAreaDataCount  ( 0 ),
      77           0 :         nWhichCons      ( rArgSet.GetPool()->GetWhich( SID_CONSOLIDATE ) ),
      78           0 :         bDlgLostFocus   ( false )
      79             : {
      80           0 :     get(pLbFunc,"func");
      81           0 :     get(pLbConsAreas,"consareas");
      82             : 
      83           0 :     get(pLbDataArea,"lbdataarea");
      84           0 :     get(pEdDataArea,"eddataarea");
      85           0 :     get(pRbDataArea,"rbdataarea");
      86             : 
      87           0 :     pRefInputEdit = pEdDataArea;
      88             : 
      89           0 :     get(pLbDestArea,"lbdestarea");
      90           0 :     get(pEdDestArea,"eddestarea");
      91           0 :     get(pRbDestArea,"rbdestarea");
      92             : 
      93           0 :     get(pExpander,"more");
      94           0 :     get(pBtnByRow,"byrow");
      95           0 :     get(pBtnByCol,"bycol");
      96           0 :     get(pBtnRefs,"refs");
      97             : 
      98           0 :     get(pBtnOk,"ok");
      99           0 :     get(pBtnCancel,"cancel");
     100           0 :     get(pBtnAdd,"add");
     101           0 :     get(pBtnRemove,"delete");
     102             : 
     103           0 :     Init();
     104           0 : }
     105             : 
     106           0 : ScConsolidateDlg::~ScConsolidateDlg()
     107             : {
     108           0 :     delete [] pAreaData;
     109           0 :     delete pRangeUtil;
     110           0 : }
     111             : 
     112           0 : void ScConsolidateDlg::Init()
     113             : {
     114             :     OSL_ENSURE( pDoc && pRangeUtil, "Error in Ctor" );
     115             : 
     116           0 :     OUString aStr;
     117           0 :     sal_uInt16 i=0;
     118             : 
     119           0 :     pRbDataArea->SetReferences(this, pEdDataArea);
     120           0 :     pEdDataArea->SetReferences(this, get<FixedText>("ftdataarea"));
     121           0 :     pRbDestArea->SetReferences(this, pEdDestArea);
     122           0 :     pEdDestArea->SetReferences(this, get<FixedText>("ftdestarea"));
     123             : 
     124           0 :     pEdDataArea ->SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
     125           0 :     pEdDestArea ->SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
     126           0 :     pLbDataArea ->SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
     127           0 :     pLbDestArea ->SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
     128           0 :     pEdDataArea ->SetModifyHdl   ( LINK( this, ScConsolidateDlg, ModifyHdl ) );
     129           0 :     pEdDestArea ->SetModifyHdl   ( LINK( this, ScConsolidateDlg, ModifyHdl ) );
     130           0 :     pLbConsAreas->SetSelectHdl   ( LINK( this, ScConsolidateDlg, SelectHdl ) );
     131           0 :     pLbDataArea ->SetSelectHdl   ( LINK( this, ScConsolidateDlg, SelectHdl ) );
     132           0 :     pLbDestArea ->SetSelectHdl   ( LINK( this, ScConsolidateDlg, SelectHdl ) );
     133           0 :     pBtnOk      ->SetClickHdl    ( LINK( this, ScConsolidateDlg, OkHdl ) );
     134           0 :     pBtnCancel  ->SetClickHdl    ( LINK( this, ScConsolidateDlg, ClickHdl ) );
     135           0 :     pBtnAdd     ->SetClickHdl    ( LINK( this, ScConsolidateDlg, ClickHdl ) );
     136           0 :     pBtnRemove  ->SetClickHdl    ( LINK( this, ScConsolidateDlg, ClickHdl ) );
     137             : 
     138           0 :     pBtnAdd->Disable();
     139           0 :     pBtnRemove->Disable();
     140             : 
     141           0 :     pBtnByRow->Check( theConsData.bByRow );
     142           0 :     pBtnByCol->Check( theConsData.bByCol );
     143           0 :     pBtnRefs->Check( theConsData.bReferenceData );
     144             : 
     145           0 :     pLbFunc->SelectEntryPos( FuncToLbPos( theConsData.eFunction ) );
     146             : 
     147             :     // Hack: pLbConsAreas used to be MultiLB. We don't have VCL builder equivalent
     148             :     // of it yet. So enable selecting multiple items here
     149           0 :     pLbConsAreas->EnableMultiSelection( true );
     150             : 
     151           0 :     pLbConsAreas->set_width_request(pLbConsAreas->approximate_char_width() * 16);
     152           0 :     pLbConsAreas->SetDropDownLineCount(5);
     153             : 
     154             :     // read consolidation areas
     155           0 :     pLbConsAreas->Clear();
     156           0 :     const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
     157           0 :     for ( i=0; i<theConsData.nDataAreaCount; i++ )
     158             :     {
     159           0 :         const ScArea& rArea = *(theConsData.ppDataAreas[i] );
     160           0 :         if ( rArea.nTab < pDoc->GetTableCount() )
     161             :         {
     162           0 :             aStr = ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
     163             :                     rArea.nColEnd, rArea.nRowEnd, rArea.nTab ).Format(
     164           0 :                         SCR_ABS_3D, pDoc, eConv );
     165           0 :             pLbConsAreas->InsertEntry( aStr );
     166             :         }
     167             :     }
     168             : 
     169           0 :     if ( theConsData.nTab < pDoc->GetTableCount() )
     170             :     {
     171           0 :         aStr = ScAddress( theConsData.nCol, theConsData.nRow, theConsData.nTab
     172           0 :                 ).Format( SCA_ABS_3D, pDoc, eConv );
     173           0 :         pEdDestArea->SetText( aStr );
     174             :     }
     175             :     else
     176           0 :         pEdDestArea->SetText(OUString());
     177             : 
     178             :     // Use the ScAreaData helper class to save those range names from the
     179             :     // RangeNames and database ranges that appear in the ListBoxes.
     180             : 
     181           0 :     ScRangeName*    pRangeNames  = pDoc->GetRangeName();
     182           0 :     ScDBCollection* pDbNames     = pDoc->GetDBCollection();
     183           0 :     size_t nRangeCount = pRangeNames ? pRangeNames->size() : 0;
     184           0 :     size_t nDbCount = pDbNames ? pDbNames->getNamedDBs().size() : 0;
     185             : 
     186           0 :     nAreaDataCount = nRangeCount+nDbCount;
     187           0 :     pAreaData      = NULL;
     188             : 
     189           0 :     if ( nAreaDataCount > 0 )
     190             :     {
     191           0 :         pAreaData = new ScAreaData[nAreaDataCount];
     192             : 
     193           0 :         OUString aStrName;
     194           0 :         sal_uInt16 nAt = 0;
     195           0 :         ScRange aRange;
     196           0 :         ScAreaNameIterator aIter( pDoc );
     197           0 :         while ( aIter.Next( aStrName, aRange ) )
     198             :         {
     199           0 :             OUString aStrArea(aRange.Format(SCA_ABS_3D, pDoc, eConv));
     200           0 :             pAreaData[nAt++].Set( aStrName, aStrArea, aIter.WasDBName() );
     201           0 :         }
     202             :     }
     203             : 
     204           0 :     FillAreaLists();
     205           0 :     ModifyHdl( pEdDestArea );
     206           0 :     pLbDataArea->SelectEntryPos( 0 );
     207           0 :     pEdDataArea->SetText(OUString());
     208           0 :     pEdDataArea->GrabFocus();
     209             : 
     210             :     //aFlSep.SetStyle( aFlSep.GetStyle() | WB_VERT );
     211             : 
     212             :     //@BugID 54702 enable/disable only in base class
     213             :     //SFX_APPWINDOW->Enable();
     214           0 : }
     215             : 
     216           0 : void ScConsolidateDlg::FillAreaLists()
     217             : {
     218           0 :     pLbDataArea->Clear();
     219           0 :     pLbDestArea->Clear();
     220           0 :     pLbDataArea->InsertEntry( aStrUndefined );
     221           0 :     pLbDestArea->InsertEntry( aStrUndefined );
     222             : 
     223           0 :     if ( pRangeUtil && pAreaData && (nAreaDataCount > 0) )
     224             :     {
     225           0 :         for ( size_t i=0;
     226           0 :               (i<nAreaDataCount) && (!pAreaData[i].aStrName.isEmpty());
     227             :               i++ )
     228             :         {
     229           0 :             pLbDataArea->InsertEntry( pAreaData[i].aStrName, i+1 );
     230             : 
     231             : //          if ( !pAreaData[i].bIsDbArea )
     232           0 :                 pLbDestArea->InsertEntry( pAreaData[i].aStrName, i+1 );
     233             :         }
     234             :     }
     235           0 : }
     236             : 
     237             : // Handover of a range within a table that has been selected by the mouse.
     238             : // This range is then shown in the reference window as new selection.
     239             : 
     240           0 : void ScConsolidateDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
     241             : {
     242           0 :     if ( pRefInputEdit )
     243             :     {
     244           0 :         if ( rRef.aStart != rRef.aEnd )
     245           0 :             RefInputStart( pRefInputEdit );
     246             : 
     247           0 :         OUString      aStr;
     248           0 :         sal_uInt16      nFmt = SCR_ABS_3D;       //!!! nCurTab is still missing
     249           0 :         const formula::FormulaGrammar::AddressConvention eConv = pDocP->GetAddressConvention();
     250             : 
     251           0 :         if ( rRef.aStart.Tab() != rRef.aEnd.Tab() )
     252           0 :             nFmt |= SCA_TAB2_3D;
     253             : 
     254           0 :         if ( pRefInputEdit == pEdDataArea)
     255           0 :             aStr = rRef.Format(nFmt, pDocP, eConv);
     256           0 :         else if ( pRefInputEdit == pEdDestArea )
     257           0 :             aStr = rRef.aStart.Format(nFmt, pDocP, eConv);
     258             : 
     259           0 :         pRefInputEdit->SetRefString( aStr );
     260           0 :         ModifyHdl( pRefInputEdit );
     261             :     }
     262           0 : }
     263             : 
     264           0 : bool ScConsolidateDlg::Close()
     265             : {
     266           0 :     return DoClose( ScConsolidateDlgWrapper::GetChildWindowId() );
     267             : }
     268             : 
     269           0 : void ScConsolidateDlg::SetActive()
     270             : {
     271           0 :     if ( bDlgLostFocus )
     272             :     {
     273           0 :         bDlgLostFocus = false;
     274             : 
     275           0 :         if ( pRefInputEdit )
     276             :         {
     277           0 :             pRefInputEdit->GrabFocus();
     278           0 :             ModifyHdl( pRefInputEdit );
     279             :         }
     280             :     }
     281             :     else
     282           0 :         GrabFocus();
     283             : 
     284           0 :     RefInputDone();
     285           0 : }
     286             : 
     287           0 : void ScConsolidateDlg::Deactivate()
     288             : {
     289           0 :     bDlgLostFocus = true;
     290           0 : }
     291             : 
     292           0 : bool ScConsolidateDlg::VerifyEdit( formula::RefEdit* pEd )
     293             : {
     294           0 :     if ( !pRangeUtil || !pDoc ||
     295           0 :          ((pEd != pEdDataArea) && (pEd != pEdDestArea)) )
     296           0 :         return false;
     297             : 
     298           0 :     SCTAB    nTab    = rViewData.GetTabNo();
     299           0 :     bool bEditOk = false;
     300           0 :     OUString theCompleteStr;
     301           0 :     const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
     302             : 
     303           0 :     if ( pEd == pEdDataArea )
     304             :     {
     305           0 :         bEditOk = pRangeUtil->IsAbsArea( pEd->GetText(), pDoc,
     306           0 :                                          nTab, &theCompleteStr, NULL, NULL, eConv );
     307             :     }
     308           0 :     else if ( pEd == pEdDestArea )
     309             :     {
     310           0 :         OUString aPosStr;
     311             : 
     312           0 :         pRangeUtil->CutPosString( pEd->GetText(), aPosStr );
     313             :         bEditOk = pRangeUtil->IsAbsPos( aPosStr, pDoc,
     314           0 :                                         nTab, &theCompleteStr, NULL, eConv );
     315             :     }
     316             : 
     317           0 :     if ( bEditOk )
     318           0 :         pEd->SetText( theCompleteStr );
     319             : 
     320           0 :     return bEditOk;
     321             : }
     322             : 
     323             : // Handler:
     324             : 
     325           0 : IMPL_LINK( ScConsolidateDlg, GetFocusHdl, Control*, pCtr )
     326             : {
     327           0 :     if ( pCtr ==(Control*)pEdDataArea ||
     328           0 :          pCtr ==(Control*)pEdDestArea)
     329             :     {
     330           0 :         pRefInputEdit = static_cast<formula::RefEdit*>(pCtr);
     331             :     }
     332           0 :     else if(pCtr ==(Control*)pLbDataArea )
     333             :     {
     334           0 :         pRefInputEdit = pEdDataArea;
     335             :     }
     336           0 :     else if(pCtr ==(Control*)pLbDestArea )
     337             :     {
     338           0 :         pRefInputEdit = pEdDestArea;
     339             :     }
     340           0 :     return 0;
     341             : }
     342             : 
     343           0 : IMPL_LINK_NOARG(ScConsolidateDlg, OkHdl)
     344             : {
     345           0 :     sal_uInt16 nDataAreaCount = pLbConsAreas->GetEntryCount();
     346             : 
     347           0 :     if ( nDataAreaCount > 0 )
     348             :     {
     349           0 :         ScRefAddress aDestAddress;
     350           0 :         SCTAB       nTab = rViewData.GetTabNo();
     351           0 :         OUString    aDestPosStr( pEdDestArea->GetText() );
     352           0 :         const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
     353             : 
     354           0 :         if ( pRangeUtil->IsAbsPos( aDestPosStr, pDoc, nTab, NULL, &aDestAddress, eConv ) )
     355             :         {
     356           0 :             ScConsolidateParam  theOutParam( theConsData );
     357           0 :             ScArea**            ppDataAreas = new ScArea*[nDataAreaCount];
     358             :             ScArea*             pArea;
     359           0 :             sal_uInt16              i=0;
     360             : 
     361           0 :             for ( i=0; i<nDataAreaCount; i++ )
     362             :             {
     363           0 :                 pArea = new ScArea;
     364             :                 pRangeUtil->MakeArea( pLbConsAreas->GetEntry( i ),
     365           0 :                                       *pArea, pDoc, nTab, eConv );
     366           0 :                 ppDataAreas[i] = pArea;
     367             :             }
     368             : 
     369           0 :             theOutParam.nCol            = aDestAddress.Col();
     370           0 :             theOutParam.nRow            = aDestAddress.Row();
     371           0 :             theOutParam.nTab            = aDestAddress.Tab();
     372           0 :             theOutParam.eFunction       = LbPosToFunc( pLbFunc->GetSelectEntryPos() );
     373           0 :             theOutParam.bByCol          = pBtnByCol->IsChecked();
     374           0 :             theOutParam.bByRow          = pBtnByRow->IsChecked();
     375           0 :             theOutParam.bReferenceData  = pBtnRefs->IsChecked();
     376           0 :             theOutParam.SetAreas( ppDataAreas, nDataAreaCount );
     377             : 
     378           0 :             for ( i=0; i<nDataAreaCount; i++ )
     379           0 :                 delete ppDataAreas[i];
     380           0 :             delete [] ppDataAreas;
     381             : 
     382           0 :             ScConsolidateItem aOutItem( nWhichCons, &theOutParam );
     383             : 
     384           0 :             SetDispatcherLock( false );
     385           0 :             SwitchToDocument();
     386           0 :             GetBindings().GetDispatcher()->Execute( SID_CONSOLIDATE,
     387             :                                       SfxCallMode::SLOT | SfxCallMode::RECORD,
     388           0 :                                       &aOutItem, 0L, 0L );
     389           0 :             Close();
     390             :         }
     391             :         else
     392             :         {
     393           0 :             INFOBOX( STR_INVALID_TABREF );
     394           0 :             pEdDestArea->GrabFocus();
     395           0 :         }
     396             :     }
     397             :     else
     398           0 :         Close(); // no area defined -> Cancel
     399           0 :     return 0;
     400             : }
     401             : 
     402           0 : IMPL_LINK( ScConsolidateDlg, ClickHdl, PushButton*, pBtn )
     403             : {
     404           0 :     if ( pBtn == pBtnCancel )
     405           0 :         Close();
     406           0 :     else if ( pBtn == pBtnAdd )
     407             :     {
     408           0 :         if ( !pEdDataArea->GetText().isEmpty() )
     409             :         {
     410           0 :             OUString    aNewEntry( pEdDataArea->GetText() );
     411           0 :             ScArea**    ppAreas = NULL;
     412           0 :             sal_uInt16      nAreaCount = 0;
     413           0 :             const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
     414             : 
     415           0 :             if ( pRangeUtil->IsAbsTabArea( aNewEntry, pDoc, &ppAreas, &nAreaCount, true, eConv ) )
     416             :             {
     417             :                 // IsAbsTabArea() creates an array of ScArea pointers,
     418             :                 // which have been created dynamically as well.
     419             :                 // These objects need to be deleted here.
     420             : 
     421           0 :                 for ( sal_uInt16 i=0; i<nAreaCount; i++ )
     422             :                 {
     423           0 :                     OUString aNewArea;
     424             : 
     425           0 :                     if ( ppAreas[i] )
     426             :                     {
     427           0 :                         const ScArea& rArea = *(ppAreas[i]);
     428           0 :                         aNewArea = ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
     429             :                                 rArea.nColEnd, rArea.nRowEnd, rArea.nTab
     430           0 :                                 ).Format(SCR_ABS_3D, pDoc, eConv);
     431             : 
     432           0 :                         if ( pLbConsAreas->GetEntryPos( aNewArea )
     433             :                              == LISTBOX_ENTRY_NOTFOUND )
     434             :                         {
     435           0 :                             pLbConsAreas->InsertEntry( aNewArea );
     436             :                         }
     437           0 :                         delete ppAreas[i];
     438             :                     }
     439           0 :                 }
     440           0 :                 delete [] ppAreas;
     441             :             }
     442           0 :             else if ( VerifyEdit( pEdDataArea ) )
     443             :             {
     444           0 :                 OUString aNewArea( pEdDataArea->GetText() );
     445             : 
     446           0 :                 if ( pLbConsAreas->GetEntryPos( aNewArea ) == LISTBOX_ENTRY_NOTFOUND )
     447           0 :                     pLbConsAreas->InsertEntry( aNewArea );
     448             :                 else
     449           0 :                     INFOBOX( STR_AREA_ALREADY_INSERTED );
     450             :             }
     451             :             else
     452             :             {
     453           0 :                 INFOBOX( STR_INVALID_TABREF );
     454           0 :                 pEdDataArea->GrabFocus();
     455           0 :             }
     456             :         }
     457             :     }
     458           0 :     else if ( pBtn == pBtnRemove )
     459             :     {
     460           0 :         while ( pLbConsAreas->GetSelectEntryCount() )
     461           0 :             pLbConsAreas->RemoveEntry( pLbConsAreas->GetSelectEntryPos() );
     462           0 :         pBtnRemove->Disable();
     463             :     }
     464           0 :     return 0;
     465             : }
     466             : 
     467           0 : IMPL_LINK( ScConsolidateDlg, SelectHdl, ListBox*, pLb )
     468             : {
     469           0 :     if ( pLb == pLbConsAreas )
     470             :     {
     471           0 :         if ( pLbConsAreas->GetSelectEntryCount() > 0 )
     472           0 :             pBtnRemove->Enable();
     473             :         else
     474           0 :             pBtnRemove->Disable();
     475             :     }
     476           0 :     else if ( (pLb == pLbDataArea) || (pLb == pLbDestArea) )
     477             :     {
     478           0 :         Edit*   pEd = (pLb == pLbDataArea) ? pEdDataArea : pEdDestArea;
     479           0 :         sal_uInt16  nSelPos = pLb->GetSelectEntryPos();
     480             : 
     481           0 :         if (    pRangeUtil
     482           0 :             && (nSelPos > 0)
     483           0 :             && (nAreaDataCount > 0)
     484           0 :             && (pAreaData != NULL) )
     485             :         {
     486           0 :             if ( static_cast<size_t>(nSelPos) <= nAreaDataCount )
     487             :             {
     488           0 :                 OUString aString( pAreaData[nSelPos-1].aStrArea );
     489             : 
     490           0 :                 if ( pLb == pLbDestArea )
     491           0 :                     pRangeUtil->CutPosString( aString, aString );
     492             : 
     493           0 :                 pEd->SetText( aString );
     494             : 
     495           0 :                 if ( pEd == pEdDataArea )
     496           0 :                     pBtnAdd->Enable();
     497           0 :             }
     498             :         }
     499             :         else
     500             :         {
     501           0 :             pEd->SetText( EMPTY_OUSTRING );
     502           0 :             if ( pEd == pEdDataArea )
     503           0 :                 pBtnAdd->Enable();
     504             :         }
     505             :     }
     506           0 :     return 0;
     507             : }
     508             : 
     509           0 : IMPL_LINK( ScConsolidateDlg, ModifyHdl, formula::RefEdit*, pEd )
     510             : {
     511           0 :     if ( pEd == pEdDataArea )
     512             :     {
     513           0 :         OUString aAreaStr( pEd->GetText() );
     514           0 :         if ( !aAreaStr.isEmpty() )
     515             :         {
     516           0 :             pBtnAdd->Enable();
     517             :         }
     518             :         else
     519           0 :             pBtnAdd->Disable();
     520             :     }
     521           0 :     else if ( pEd == pEdDestArea )
     522             :     {
     523           0 :         pLbDestArea->SelectEntryPos(0);
     524             :     }
     525           0 :     return 0;
     526             : }
     527             : 
     528             : // TODO: generalize!
     529             : // Resource of the ListBox and these two conversion methods are also in
     530             : // tpsubt and everywhere, where StarCalc functions are selectable.
     531             : 
     532           0 : ScSubTotalFunc ScConsolidateDlg::LbPosToFunc( sal_uInt16 nPos )
     533             : {
     534           0 :     switch ( nPos )
     535             :     {
     536           0 :         case  2:    return SUBTOTAL_FUNC_AVE;
     537           0 :         case  6:    return SUBTOTAL_FUNC_CNT;
     538           0 :         case  1:    return SUBTOTAL_FUNC_CNT2;
     539           0 :         case  3:    return SUBTOTAL_FUNC_MAX;
     540           0 :         case  4:    return SUBTOTAL_FUNC_MIN;
     541           0 :         case  5:    return SUBTOTAL_FUNC_PROD;
     542           0 :         case  7:    return SUBTOTAL_FUNC_STD;
     543           0 :         case  8:    return SUBTOTAL_FUNC_STDP;
     544           0 :         case  9:    return SUBTOTAL_FUNC_VAR;
     545           0 :         case 10:    return SUBTOTAL_FUNC_VARP;
     546             :         case  0:
     547             :         default:
     548           0 :             return SUBTOTAL_FUNC_SUM;
     549             :     }
     550             : }
     551             : 
     552           0 : sal_uInt16 ScConsolidateDlg::FuncToLbPos( ScSubTotalFunc eFunc )
     553             : {
     554           0 :     switch ( eFunc )
     555             :     {
     556           0 :         case SUBTOTAL_FUNC_AVE:     return 2;
     557           0 :         case SUBTOTAL_FUNC_CNT:     return 6;
     558           0 :         case SUBTOTAL_FUNC_CNT2:    return 1;
     559           0 :         case SUBTOTAL_FUNC_MAX:     return 3;
     560           0 :         case SUBTOTAL_FUNC_MIN:     return 4;
     561           0 :         case SUBTOTAL_FUNC_PROD:    return 5;
     562           0 :         case SUBTOTAL_FUNC_STD:     return 7;
     563           0 :         case SUBTOTAL_FUNC_STDP:    return 8;
     564           0 :         case SUBTOTAL_FUNC_VAR:     return 9;
     565           0 :         case SUBTOTAL_FUNC_VARP:    return 10;
     566             :         case SUBTOTAL_FUNC_NONE:
     567             :         case SUBTOTAL_FUNC_SUM:
     568             :         default:
     569           0 :             return 0;
     570             :     }
     571         228 : }
     572             : 
     573             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10