LCOV - code coverage report
Current view: top level - sc/source/ui/dbgui - consdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 281 0.0 %
Date: 2012-08-25 Functions: 0 25 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 634 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <sfx2/dispatch.hxx>
      30                 :            : 
      31                 :            : #include "tabvwsh.hxx"
      32                 :            : #include "uiitems.hxx"
      33                 :            : #include "dbdata.hxx"
      34                 :            : #include "rangenam.hxx"
      35                 :            : #include "rangeutl.hxx"
      36                 :            : #include "reffact.hxx"
      37                 :            : #include "document.hxx"
      38                 :            : #include "scresid.hxx"
      39                 :            : 
      40                 :            : #include "globstr.hrc"
      41                 :            : #include "consdlg.hrc"
      42                 :            : 
      43                 :            : #define _CONSDLG_CXX
      44                 :            : #include "consdlg.hxx"
      45                 :            : #undef _CONSDLG_CXX
      46                 :            : #include <vcl/msgbox.hxx>
      47                 :            : 
      48                 :            : #define INFOBOX(id) InfoBox(this, ScGlobal::GetRscString(id)).Execute()
      49                 :            : 
      50                 :            : //============================================================================
      51                 :            : //  class ScAreaData
      52                 :            : 
      53                 :            : class ScAreaData
      54                 :            : {
      55                 :            : public:
      56         [ #  # ]:          0 :     ScAreaData()  {}
      57         [ #  # ]:          0 :     ~ScAreaData() {}
      58                 :            : 
      59                 :          0 :     void Set( const String& rName, const String& rArea, sal_Bool bDb )
      60                 :            :                 {
      61                 :          0 :                     aStrName  = rName;
      62                 :          0 :                     aStrArea  = rArea;
      63                 :          0 :                     bIsDbArea = bDb;
      64                 :          0 :                 }
      65                 :            : 
      66                 :            :     String  aStrName;
      67                 :            :     String  aStrArea;
      68                 :            :     sal_Bool    bIsDbArea;
      69                 :            : };
      70                 :            : 
      71                 :            : 
      72                 :            : //============================================================================
      73                 :            : //  class ScConsolidateDialog
      74                 :            : 
      75                 :            : 
      76                 :          0 : ScConsolidateDlg::ScConsolidateDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
      77                 :            :                                     const SfxItemSet&   rArgSet )
      78                 :            : 
      79                 :            :     :   ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_CONSOLIDATE ),
      80                 :            :         //
      81                 :            :         aFtFunc         ( this, ScResId( FT_FUNC ) ),
      82                 :            :         aLbFunc         ( this, ScResId( LB_FUNC ) ),
      83                 :            : 
      84                 :            :         aFtConsAreas    ( this, ScResId( FT_CONSAREAS ) ),
      85                 :            :         aLbConsAreas    ( this, ScResId( LB_CONSAREAS ) ),
      86                 :            : 
      87                 :            :         aLbDataArea     ( this, ScResId( LB_DATA_AREA ) ),
      88                 :            :         aFtDataArea     ( this, ScResId( FT_DATA_AREA ) ),
      89                 :            :         aEdDataArea     ( this, this, ScResId( ED_DATA_AREA ) ),
      90                 :            :         aRbDataArea     ( this, ScResId( RB_DATA_AREA ), &aEdDataArea, this ),
      91                 :            : 
      92                 :            :         aLbDestArea     ( this, ScResId( LB_DEST_AREA ) ),
      93                 :            :         aFtDestArea     ( this, ScResId( FT_DEST_AREA ) ),
      94                 :            :         aEdDestArea     ( this, this, ScResId( ED_DEST_AREA ) ),
      95                 :            :         aRbDestArea     ( this, ScResId( RB_DEST_AREA ), &aEdDestArea, this),
      96                 :            : 
      97                 :            :         aFlConsBy       ( this, ScResId( FL_CONSBY ) ),
      98                 :            :         aBtnByRow       ( this, ScResId( BTN_BYROW ) ),
      99                 :            :         aBtnByCol       ( this, ScResId( BTN_BYCOL) ),
     100                 :            : 
     101                 :            :         aFlSep          ( this, ScResId( FL_SEP ) ),
     102                 :            :         aFlOptions      ( this, ScResId( FL_OPTIONS ) ),
     103                 :            :         aBtnRefs        ( this, ScResId( BTN_REFS ) ),
     104                 :            : 
     105                 :            :         aBtnOk          ( this, ScResId( BTN_OK ) ),
     106                 :            :         aBtnCancel      ( this, ScResId( BTN_CANCEL ) ),
     107                 :            :         aBtnHelp        ( this, ScResId( BTN_HELP ) ),
     108                 :            :         aBtnAdd         ( this, ScResId( BTN_ADD ) ),
     109                 :            :         aBtnRemove      ( this, ScResId( BTN_REMOVE ) ),
     110                 :            :         aBtnMore        ( this, ScResId( BTN_MORE ) ),
     111                 :            : 
     112                 :            :         aStrUndefined   ( ScResId( SCSTR_UNDEFINED ) ),
     113                 :            :         //
     114                 :            :         theConsData     ( ((const ScConsolidateItem&)
     115                 :            :                            rArgSet.Get( rArgSet.GetPool()->
     116 [ #  # ][ #  # ]:          0 :                                             GetWhich( SID_CONSOLIDATE ) )
     117                 :          0 :                                       ).GetData() ),
     118         [ #  # ]:          0 :         pViewData       ( ((ScTabViewShell*)SfxViewShell::Current())->
     119                 :          0 :                                 GetViewData() ),
     120         [ #  # ]:          0 :         pDoc            ( ((ScTabViewShell*)SfxViewShell::Current())->
     121         [ #  # ]:          0 :                                 GetViewData()->GetDocument() ),
     122                 :          0 :         pRangeUtil      ( new ScRangeUtil ),
     123                 :            :         pAreaData       ( NULL ),
     124                 :            :         nAreaDataCount  ( 0 ),
     125         [ #  # ]:          0 :         nWhichCons      ( rArgSet.GetPool()->GetWhich( SID_CONSOLIDATE ) ),
     126                 :            : 
     127 [ #  # ][ #  # ]:          0 :         pRefInputEdit   ( &aEdDataArea )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     128                 :            : {
     129         [ #  # ]:          0 :     Init();
     130         [ #  # ]:          0 :     FreeResource();
     131                 :          0 : }
     132                 :            : 
     133                 :            : 
     134                 :            : //----------------------------------------------------------------------------
     135                 :            : 
     136 [ #  # ][ #  # ]:          0 : ScConsolidateDlg::~ScConsolidateDlg()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     137                 :            : {
     138 [ #  # ][ #  # ]:          0 :     delete [] pAreaData;
                 [ #  # ]
     139         [ #  # ]:          0 :     delete pRangeUtil;
     140         [ #  # ]:          0 : }
     141                 :            : 
     142                 :            : 
     143                 :            : //----------------------------------------------------------------------------
     144                 :            : 
     145                 :          0 : void ScConsolidateDlg::Init()
     146                 :            : {
     147                 :            :     OSL_ENSURE( pViewData && pDoc && pRangeUtil, "Error in Ctor" );
     148                 :            : 
     149         [ #  # ]:          0 :     String aStr;
     150                 :          0 :     sal_uInt16 i=0;
     151                 :            : 
     152         [ #  # ]:          0 :     aEdDataArea .SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
     153         [ #  # ]:          0 :     aEdDestArea .SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
     154         [ #  # ]:          0 :     aLbDataArea .SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
     155         [ #  # ]:          0 :     aLbDestArea .SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
     156         [ #  # ]:          0 :     aEdDataArea .SetModifyHdl   ( LINK( this, ScConsolidateDlg, ModifyHdl ) );
     157         [ #  # ]:          0 :     aEdDestArea .SetModifyHdl   ( LINK( this, ScConsolidateDlg, ModifyHdl ) );
     158         [ #  # ]:          0 :     aLbConsAreas.SetSelectHdl   ( LINK( this, ScConsolidateDlg, SelectHdl ) );
     159         [ #  # ]:          0 :     aLbDataArea .SetSelectHdl   ( LINK( this, ScConsolidateDlg, SelectHdl ) );
     160         [ #  # ]:          0 :     aLbDestArea .SetSelectHdl   ( LINK( this, ScConsolidateDlg, SelectHdl ) );
     161         [ #  # ]:          0 :     aBtnOk      .SetClickHdl    ( LINK( this, ScConsolidateDlg, OkHdl ) );
     162         [ #  # ]:          0 :     aBtnCancel  .SetClickHdl    ( LINK( this, ScConsolidateDlg, ClickHdl ) );
     163         [ #  # ]:          0 :     aBtnAdd     .SetClickHdl    ( LINK( this, ScConsolidateDlg, ClickHdl ) );
     164         [ #  # ]:          0 :     aBtnRemove  .SetClickHdl    ( LINK( this, ScConsolidateDlg, ClickHdl ) );
     165                 :            : 
     166         [ #  # ]:          0 :     aBtnMore.AddWindow( &aFlConsBy );
     167         [ #  # ]:          0 :     aBtnMore.AddWindow( &aBtnByRow );
     168         [ #  # ]:          0 :     aBtnMore.AddWindow( &aBtnByCol );
     169         [ #  # ]:          0 :     aBtnMore.AddWindow( &aFlSep );
     170         [ #  # ]:          0 :     aBtnMore.AddWindow( &aFlOptions );
     171         [ #  # ]:          0 :     aBtnMore.AddWindow( &aBtnRefs );
     172                 :            : 
     173         [ #  # ]:          0 :     aBtnAdd.Disable();
     174         [ #  # ]:          0 :     aBtnRemove.Disable();
     175                 :            : 
     176         [ #  # ]:          0 :     aBtnByRow.Check( theConsData.bByRow );
     177         [ #  # ]:          0 :     aBtnByCol.Check( theConsData.bByCol );
     178         [ #  # ]:          0 :     aBtnRefs .Check( theConsData.bReferenceData );
     179                 :            : 
     180         [ #  # ]:          0 :     aLbFunc.SelectEntryPos( FuncToLbPos( theConsData.eFunction ) );
     181                 :            : 
     182                 :            :     // Einlesen der Konsolidierungsbereiche
     183         [ #  # ]:          0 :     aLbConsAreas.Clear();
     184         [ #  # ]:          0 :     const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
     185         [ #  # ]:          0 :     for ( i=0; i<theConsData.nDataAreaCount; i++ )
     186                 :            :     {
     187                 :          0 :         const ScArea& rArea = *(theConsData.ppDataAreas[i] );
     188 [ #  # ][ #  # ]:          0 :         if ( rArea.nTab < pDoc->GetTableCount() )
     189                 :            :         {
     190                 :            :             ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
     191                 :            :                     rArea.nColEnd, rArea.nRowEnd, rArea.nTab ).Format( aStr,
     192         [ #  # ]:          0 :                         SCR_ABS_3D, pDoc, eConv );
     193         [ #  # ]:          0 :             aLbConsAreas.InsertEntry( aStr );
     194                 :            :         }
     195                 :            :     }
     196                 :            : 
     197 [ #  # ][ #  # ]:          0 :     if ( theConsData.nTab < pDoc->GetTableCount() )
     198                 :            :     {
     199                 :            :         ScAddress( theConsData.nCol, theConsData.nRow, theConsData.nTab
     200         [ #  # ]:          0 :                 ).Format( aStr, SCA_ABS_3D, pDoc, eConv );
     201         [ #  # ]:          0 :         aEdDestArea.SetText( aStr );
     202                 :            :     }
     203                 :            :     else
     204 [ #  # ][ #  # ]:          0 :         aEdDestArea.SetText( EMPTY_STRING );
     205                 :            : 
     206                 :            :     //----------------------------------------------------------
     207                 :            : 
     208                 :            :     /*
     209                 :            :      * Aus den RangeNames und Datenbankbereichen werden sich
     210                 :            :      * in der Hilfsklasse ScAreaData die Bereichsnamen gemerkt,
     211                 :            :      * die in den ListBoxen erscheinen.
     212                 :            :      */
     213                 :            : 
     214         [ #  # ]:          0 :     ScRangeName*    pRangeNames  = pDoc->GetRangeName();
     215         [ #  # ]:          0 :     ScDBCollection* pDbNames     = pDoc->GetDBCollection();
     216 [ #  # ][ #  # ]:          0 :     size_t nRangeCount = pRangeNames ? pRangeNames->size() : 0;
     217 [ #  # ][ #  # ]:          0 :     size_t nDbCount = pDbNames ? pDbNames->getNamedDBs().size() : 0;
                 [ #  # ]
     218                 :            : 
     219                 :          0 :     nAreaDataCount = nRangeCount+nDbCount;
     220                 :          0 :     pAreaData      = NULL;
     221                 :            : 
     222         [ #  # ]:          0 :     if ( nAreaDataCount > 0 )
     223                 :            :     {
     224 [ #  # ][ #  # ]:          0 :         pAreaData = new ScAreaData[nAreaDataCount];
           [ #  #  #  #  
                   #  # ]
     225                 :            : 
     226         [ #  # ]:          0 :         String aStrName;
     227         [ #  # ]:          0 :         String aStrArea;
     228                 :          0 :         sal_uInt16 nAt = 0;
     229                 :          0 :         ScRange aRange;
     230         [ #  # ]:          0 :         ScAreaNameIterator aIter( pDoc );
     231 [ #  # ][ #  # ]:          0 :         while ( aIter.Next( aStrName, aRange ) )
     232                 :            :         {
     233         [ #  # ]:          0 :             aRange.Format( aStrArea, SCA_ABS_3D, pDoc, eConv );
     234         [ #  # ]:          0 :             pAreaData[nAt++].Set( aStrName, aStrArea, aIter.WasDBName() );
     235 [ #  # ][ #  # ]:          0 :         }
     236                 :            :     }
     237                 :            : 
     238         [ #  # ]:          0 :     FillAreaLists();
     239         [ #  # ]:          0 :     ModifyHdl( &aEdDestArea );
     240         [ #  # ]:          0 :     aLbDataArea.SelectEntryPos( 0 );
     241 [ #  # ][ #  # ]:          0 :     aEdDataArea.SetText( EMPTY_STRING );
     242         [ #  # ]:          0 :     aEdDataArea.GrabFocus();
     243                 :            : 
     244 [ #  # ][ #  # ]:          0 :     aFlSep.SetStyle( aFlSep.GetStyle() | WB_VERT );
                 [ #  # ]
     245                 :            : 
     246                 :            :     //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
     247                 :            :     //SFX_APPWINDOW->Enable();
     248                 :          0 : }
     249                 :            : 
     250                 :            : 
     251                 :            : //----------------------------------------------------------------------------
     252                 :          0 : void ScConsolidateDlg::FillAreaLists()
     253                 :            : {
     254                 :          0 :     aLbDataArea.Clear();
     255                 :          0 :     aLbDestArea.Clear();
     256                 :          0 :     aLbDataArea.InsertEntry( aStrUndefined );
     257                 :          0 :     aLbDestArea.InsertEntry( aStrUndefined );
     258                 :            : 
     259 [ #  # ][ #  # ]:          0 :     if ( pRangeUtil && pAreaData && (nAreaDataCount > 0) )
                 [ #  # ]
     260                 :            :     {
     261         [ #  # ]:          0 :         String aString;
     262                 :            : 
     263   [ #  #  #  # ]:          0 :         for ( size_t i=0;
                 [ #  # ]
     264                 :          0 :               (i<nAreaDataCount) && (pAreaData[i].aStrName.Len()>0);
     265                 :            :               i++ )
     266                 :            :         {
     267         [ #  # ]:          0 :             aLbDataArea.InsertEntry( pAreaData[i].aStrName, i+1 );
     268                 :            : 
     269                 :            : //          if ( !pAreaData[i].bIsDbArea )
     270         [ #  # ]:          0 :                 aLbDestArea.InsertEntry( pAreaData[i].aStrName, i+1 );
     271         [ #  # ]:          0 :         }
     272                 :            :     }
     273                 :          0 : }
     274                 :            : 
     275                 :            : 
     276                 :            : //----------------------------------------------------------------------------
     277                 :            : // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
     278                 :            : //  neue Selektion im Referenz-Fenster angezeigt wird.
     279                 :            : 
     280                 :            : 
     281                 :          0 : void ScConsolidateDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
     282                 :            : {
     283         [ #  # ]:          0 :     if ( pRefInputEdit )
     284                 :            :     {
     285         [ #  # ]:          0 :         if ( rRef.aStart != rRef.aEnd )
     286         [ #  # ]:          0 :             RefInputStart( pRefInputEdit );
     287                 :            : 
     288         [ #  # ]:          0 :         String      aStr;
     289                 :          0 :         sal_uInt16      nFmt = SCR_ABS_3D;       //!!! nCurTab fehlt noch
     290         [ #  # ]:          0 :         const formula::FormulaGrammar::AddressConvention eConv = pDocP->GetAddressConvention();
     291                 :            : 
     292         [ #  # ]:          0 :         if ( rRef.aStart.Tab() != rRef.aEnd.Tab() )
     293                 :          0 :             nFmt |= SCA_TAB2_3D;
     294                 :            : 
     295         [ #  # ]:          0 :         if ( pRefInputEdit == &aEdDataArea)
     296         [ #  # ]:          0 :             rRef.Format( aStr, nFmt, pDocP, eConv );
     297         [ #  # ]:          0 :         else if ( pRefInputEdit == &aEdDestArea )
     298         [ #  # ]:          0 :             rRef.aStart.Format( aStr, nFmt, pDocP, eConv );
     299                 :            : 
     300 [ #  # ][ #  # ]:          0 :         pRefInputEdit->SetRefString( aStr );
     301                 :            :     }
     302                 :            : 
     303                 :          0 :     ModifyHdl( pRefInputEdit );
     304                 :          0 : }
     305                 :            : 
     306                 :            : 
     307                 :            : //----------------------------------------------------------------------------
     308                 :            : 
     309                 :          0 : sal_Bool ScConsolidateDlg::Close()
     310                 :            : {
     311                 :          0 :     return DoClose( ScConsolidateDlgWrapper::GetChildWindowId() );
     312                 :            : }
     313                 :            : 
     314                 :            : 
     315                 :            : //----------------------------------------------------------------------------
     316                 :            : 
     317                 :          0 : void ScConsolidateDlg::SetActive()
     318                 :            : {
     319         [ #  # ]:          0 :     if ( bDlgLostFocus )
     320                 :            :     {
     321                 :          0 :         bDlgLostFocus = false;
     322                 :            : 
     323         [ #  # ]:          0 :         if ( pRefInputEdit )
     324                 :            :         {
     325                 :          0 :             pRefInputEdit->GrabFocus();
     326                 :          0 :             ModifyHdl( pRefInputEdit );
     327                 :            :         }
     328                 :            :     }
     329                 :            :     else
     330                 :          0 :         GrabFocus();
     331                 :            : 
     332                 :          0 :     RefInputDone();
     333                 :          0 : }
     334                 :            : 
     335                 :            : 
     336                 :            : //----------------------------------------------------------------------------
     337                 :            : 
     338                 :          0 : void ScConsolidateDlg::Deactivate()
     339                 :            : {
     340                 :          0 :     bDlgLostFocus = sal_True;
     341                 :          0 : }
     342                 :            : 
     343                 :            : 
     344                 :            : //----------------------------------------------------------------------------
     345                 :            : 
     346                 :          0 : sal_Bool ScConsolidateDlg::VerifyEdit( formula::RefEdit* pEd )
     347                 :            : {
     348 [ #  # ][ #  # ]:          0 :     if ( !pRangeUtil || !pDoc || !pViewData ||
         [ #  # ][ #  # ]
                 [ #  # ]
     349                 :            :          ((pEd != &aEdDataArea) && (pEd != &aEdDestArea)) )
     350                 :          0 :         return false;
     351                 :            : 
     352                 :          0 :     SCTAB   nTab    = pViewData->GetTabNo();
     353                 :          0 :     sal_Bool    bEditOk = false;
     354         [ #  # ]:          0 :     String  theCompleteStr;
     355         [ #  # ]:          0 :     const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
     356                 :            : 
     357         [ #  # ]:          0 :     if ( pEd == &aEdDataArea )
     358                 :            :     {
     359                 :          0 :         bEditOk = pRangeUtil->IsAbsArea( pEd->GetText(), pDoc,
     360 [ #  # ][ #  # ]:          0 :                                          nTab, &theCompleteStr, NULL, NULL, eConv );
                 [ #  # ]
     361                 :            :     }
     362         [ #  # ]:          0 :     else if ( pEd == &aEdDestArea )
     363                 :            :     {
     364         [ #  # ]:          0 :         String aPosStr;
     365                 :            : 
     366 [ #  # ][ #  # ]:          0 :         pRangeUtil->CutPosString( pEd->GetText(), aPosStr );
                 [ #  # ]
     367                 :            :         bEditOk = pRangeUtil->IsAbsPos( aPosStr, pDoc,
     368 [ #  # ][ #  # ]:          0 :                                         nTab, &theCompleteStr, NULL, eConv );
     369                 :            :     }
     370                 :            : 
     371         [ #  # ]:          0 :     if ( bEditOk )
     372         [ #  # ]:          0 :         pEd->SetText( theCompleteStr );
     373                 :            : 
     374         [ #  # ]:          0 :     return bEditOk;
     375                 :            : }
     376                 :            : 
     377                 :            : 
     378                 :            : //----------------------------------------------------------------------------
     379                 :            : // Handler:
     380                 :            : // ========
     381                 :            : 
     382                 :          0 : IMPL_LINK( ScConsolidateDlg, GetFocusHdl, Control*, pCtr )
     383                 :            : {
     384 [ #  # ][ #  # ]:          0 :     if ( pCtr ==(Control*)&aEdDataArea ||
     385                 :            :          pCtr ==(Control*)&aEdDestArea)
     386                 :            :     {
     387                 :          0 :         pRefInputEdit = (formula::RefEdit*)pCtr;
     388                 :            :     }
     389         [ #  # ]:          0 :     else if(pCtr ==(Control*)&aLbDataArea )
     390                 :            :     {
     391                 :          0 :         pRefInputEdit = &aEdDataArea;
     392                 :            :     }
     393         [ #  # ]:          0 :     else if(pCtr ==(Control*)&aLbDestArea )
     394                 :            :     {
     395                 :          0 :         pRefInputEdit = &aEdDestArea;
     396                 :            :     }
     397                 :          0 :     return 0;
     398                 :            : }
     399                 :            : 
     400                 :            : 
     401                 :            : //----------------------------------------------------------------------------
     402                 :            : 
     403                 :          0 : IMPL_LINK_NOARG(ScConsolidateDlg, OkHdl)
     404                 :            : {
     405                 :          0 :     sal_uInt16 nDataAreaCount = aLbConsAreas.GetEntryCount();
     406                 :            : 
     407         [ #  # ]:          0 :     if ( nDataAreaCount > 0 )
     408                 :            :     {
     409                 :          0 :         ScRefAddress aDestAddress;
     410                 :          0 :         SCTAB       nTab = pViewData->GetTabNo();
     411         [ #  # ]:          0 :         String      aDestPosStr( aEdDestArea.GetText() );
     412         [ #  # ]:          0 :         const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
     413                 :            : 
     414 [ #  # ][ #  # ]:          0 :         if ( pRangeUtil->IsAbsPos( aDestPosStr, pDoc, nTab, NULL, &aDestAddress, eConv ) )
     415                 :            :         {
     416         [ #  # ]:          0 :             ScConsolidateParam  theOutParam( theConsData );
     417         [ #  # ]:          0 :             ScArea**            ppDataAreas = new ScArea*[nDataAreaCount];
     418                 :            :             ScArea*             pArea;
     419                 :          0 :             sal_uInt16              i=0;
     420                 :            : 
     421         [ #  # ]:          0 :             for ( i=0; i<nDataAreaCount; i++ )
     422                 :            :             {
     423 [ #  # ][ #  # ]:          0 :                 pArea = new ScArea;
     424                 :            :                 pRangeUtil->MakeArea( aLbConsAreas.GetEntry( i ),
     425 [ #  # ][ #  # ]:          0 :                                       *pArea, pDoc, nTab, eConv );
                 [ #  # ]
     426                 :          0 :                 ppDataAreas[i] = pArea;
     427                 :            :             }
     428                 :            : 
     429                 :          0 :             theOutParam.nCol            = aDestAddress.Col();
     430                 :          0 :             theOutParam.nRow            = aDestAddress.Row();
     431                 :          0 :             theOutParam.nTab            = aDestAddress.Tab();
     432         [ #  # ]:          0 :             theOutParam.eFunction       = LbPosToFunc( aLbFunc.GetSelectEntryPos() );
     433         [ #  # ]:          0 :             theOutParam.bByCol          = aBtnByCol.IsChecked();
     434         [ #  # ]:          0 :             theOutParam.bByRow          = aBtnByRow.IsChecked();
     435         [ #  # ]:          0 :             theOutParam.bReferenceData  = aBtnRefs.IsChecked();
     436         [ #  # ]:          0 :             theOutParam.SetAreas( ppDataAreas, nDataAreaCount );
     437                 :            : 
     438         [ #  # ]:          0 :             for ( i=0; i<nDataAreaCount; i++ )
     439                 :          0 :                 delete ppDataAreas[i];
     440         [ #  # ]:          0 :             delete [] ppDataAreas;
     441                 :            : 
     442         [ #  # ]:          0 :             ScConsolidateItem aOutItem( nWhichCons, &theOutParam );
     443                 :            : 
     444         [ #  # ]:          0 :             SetDispatcherLock( false );
     445         [ #  # ]:          0 :             SwitchToDocument();
     446                 :          0 :             GetBindings().GetDispatcher()->Execute( SID_CONSOLIDATE,
     447                 :            :                                       SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
     448         [ #  # ]:          0 :                                       &aOutItem, 0L, 0L );
     449 [ #  # ][ #  # ]:          0 :             Close();
                 [ #  # ]
     450                 :            :         }
     451                 :            :         else
     452                 :            :         {
     453 [ #  # ][ #  # ]:          0 :             INFOBOX( STR_INVALID_TABREF );
         [ #  # ][ #  # ]
     454         [ #  # ]:          0 :             aEdDestArea.GrabFocus();
     455         [ #  # ]:          0 :         }
     456                 :            :     }
     457                 :            :     else
     458                 :          0 :         Close(); // keine Datenbereiche definiert -> Cancel
     459                 :          0 :     return 0;
     460                 :            : }
     461                 :            : 
     462                 :            : 
     463                 :            : //----------------------------------------------------------------------------
     464                 :            : 
     465                 :          0 : IMPL_LINK( ScConsolidateDlg, ClickHdl, PushButton*, pBtn )
     466                 :            : {
     467         [ #  # ]:          0 :     if ( pBtn == &aBtnCancel )
     468                 :          0 :         Close();
     469         [ #  # ]:          0 :     else if ( pBtn == &aBtnAdd )
     470                 :            :     {
     471         [ #  # ]:          0 :         if ( aEdDataArea.GetText().Len() > 0 )
     472                 :            :         {
     473         [ #  # ]:          0 :             String      aNewEntry( aEdDataArea.GetText() );
     474                 :          0 :             ScArea**    ppAreas = NULL;
     475                 :          0 :             sal_uInt16      nAreaCount = 0;
     476         [ #  # ]:          0 :             const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
     477                 :            : 
     478 [ #  # ][ #  # ]:          0 :             if ( pRangeUtil->IsAbsTabArea( aNewEntry, pDoc, &ppAreas, &nAreaCount, sal_True, eConv ) )
     479                 :            :             {
     480                 :            :                 // IsAbsTabArea() legt ein Array von ScArea-Zeigern an,
     481                 :            :                 // welche ebenfalls dynamisch erzeugt wurden.
     482                 :            :                 // Diese Objekte muessen hier abgeraeumt werden.
     483                 :            : 
     484         [ #  # ]:          0 :                 for ( sal_uInt16 i=0; i<nAreaCount; i++ )
     485                 :            :                 {
     486         [ #  # ]:          0 :                     String aNewArea;
     487                 :            : 
     488         [ #  # ]:          0 :                     if ( ppAreas[i] )
     489                 :            :                     {
     490                 :          0 :                         const ScArea& rArea = *(ppAreas[i]);
     491                 :            :                         ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
     492                 :            :                                 rArea.nColEnd, rArea.nRowEnd, rArea.nTab
     493         [ #  # ]:          0 :                                 ).Format( aNewArea, SCR_ABS_3D, pDoc, eConv );
     494                 :            : 
     495 [ #  # ][ #  # ]:          0 :                         if ( aLbConsAreas.GetEntryPos( aNewArea )
     496                 :            :                              == LISTBOX_ENTRY_NOTFOUND )
     497                 :            :                         {
     498         [ #  # ]:          0 :                             aLbConsAreas.InsertEntry( aNewArea );
     499                 :            :                         }
     500                 :          0 :                         delete ppAreas[i];
     501                 :            :                     }
     502         [ #  # ]:          0 :                 }
     503         [ #  # ]:          0 :                 delete [] ppAreas;
     504                 :            :             }
     505 [ #  # ][ #  # ]:          0 :             else if ( VerifyEdit( &aEdDataArea ) )
     506                 :            :             {
     507         [ #  # ]:          0 :                 String aNewArea( aEdDataArea.GetText() );
     508                 :            : 
     509 [ #  # ][ #  # ]:          0 :                 if ( aLbConsAreas.GetEntryPos( aNewArea ) == LISTBOX_ENTRY_NOTFOUND )
     510         [ #  # ]:          0 :                     aLbConsAreas.InsertEntry( aNewArea );
     511                 :            :                 else
     512 [ #  # ][ #  # ]:          0 :                     INFOBOX( STR_AREA_ALREADY_INSERTED );
         [ #  # ][ #  # ]
                 [ #  # ]
     513                 :            :             }
     514                 :            :             else
     515                 :            :             {
     516 [ #  # ][ #  # ]:          0 :                 INFOBOX( STR_INVALID_TABREF );
         [ #  # ][ #  # ]
     517         [ #  # ]:          0 :                 aEdDataArea.GrabFocus();
     518         [ #  # ]:          0 :             }
     519                 :            :         }
     520                 :            :     }
     521         [ #  # ]:          0 :     else if ( pBtn == &aBtnRemove )
     522                 :            :     {
     523         [ #  # ]:          0 :         while ( aLbConsAreas.GetSelectEntryCount() )
     524                 :          0 :             aLbConsAreas.RemoveEntry( aLbConsAreas.GetSelectEntryPos() );
     525                 :          0 :         aBtnRemove.Disable();
     526                 :            :     }
     527                 :          0 :     return 0;
     528                 :            : }
     529                 :            : 
     530                 :            : 
     531                 :            : //----------------------------------------------------------------------------
     532                 :            : 
     533                 :          0 : IMPL_LINK( ScConsolidateDlg, SelectHdl, ListBox*, pLb )
     534                 :            : {
     535         [ #  # ]:          0 :     if ( pLb == &aLbConsAreas )
     536                 :            :     {
     537         [ #  # ]:          0 :         if ( aLbConsAreas.GetSelectEntryCount() > 0 )
     538                 :          0 :             aBtnRemove.Enable();
     539                 :            :         else
     540                 :          0 :             aBtnRemove.Disable();
     541                 :            :     }
     542 [ #  # ][ #  # ]:          0 :     else if ( (pLb == &aLbDataArea) || (pLb == &aLbDestArea) )
     543                 :            :     {
     544         [ #  # ]:          0 :         Edit*   pEd = (pLb == &aLbDataArea) ? &aEdDataArea : &aEdDestArea;
     545                 :          0 :         sal_uInt16  nSelPos = pLb->GetSelectEntryPos();
     546                 :            : 
     547 [ #  # ][ #  # ]:          0 :         if (    pRangeUtil
         [ #  # ][ #  # ]
     548                 :            :             && (nSelPos > 0)
     549                 :            :             && (nAreaDataCount > 0)
     550                 :            :             && (pAreaData != NULL) )
     551                 :            :         {
     552         [ #  # ]:          0 :             if ( static_cast<size_t>(nSelPos) <= nAreaDataCount )
     553                 :            :             {
     554         [ #  # ]:          0 :                 String aString( pAreaData[nSelPos-1].aStrArea );
     555                 :            : 
     556         [ #  # ]:          0 :                 if ( pLb == &aLbDestArea )
     557         [ #  # ]:          0 :                     pRangeUtil->CutPosString( aString, aString );
     558                 :            : 
     559         [ #  # ]:          0 :                 pEd->SetText( aString );
     560                 :            : 
     561         [ #  # ]:          0 :                 if ( pEd == &aEdDataArea )
     562 [ #  # ][ #  # ]:          0 :                     aBtnAdd.Enable();
     563                 :          0 :             }
     564                 :            :         }
     565                 :            :         else
     566                 :            :         {
     567                 :          0 :             pEd->SetText( EMPTY_STRING );
     568         [ #  # ]:          0 :             if ( pEd == &aEdDataArea )
     569                 :          0 :                 aBtnAdd.Enable();
     570                 :            :         }
     571                 :            :     }
     572                 :          0 :     return 0;
     573                 :            : }
     574                 :            : 
     575                 :            : 
     576                 :            : //----------------------------------------------------------------------------
     577                 :            : 
     578                 :          0 : IMPL_LINK( ScConsolidateDlg, ModifyHdl, formula::RefEdit*, pEd )
     579                 :            : {
     580         [ #  # ]:          0 :     if ( pEd == &aEdDataArea )
     581                 :            :     {
     582         [ #  # ]:          0 :         String aAreaStr( pEd->GetText() );
     583         [ #  # ]:          0 :         if ( aAreaStr.Len() > 0 )
     584                 :            :         {
     585         [ #  # ]:          0 :             aBtnAdd.Enable();
     586                 :            :         }
     587                 :            :         else
     588 [ #  # ][ #  # ]:          0 :             aBtnAdd.Disable();
     589                 :            :     }
     590         [ #  # ]:          0 :     else if ( pEd == &aEdDestArea )
     591                 :            :     {
     592                 :          0 :         aLbDestArea.SelectEntryPos(0);
     593                 :            :     }
     594                 :          0 :     return 0;
     595                 :            : }
     596                 :            : 
     597                 :            : 
     598                 :            : //----------------------------------------------------------------------------
     599                 :            : // Verallgemeinern!!! :
     600                 :            : // Resource der ListBox und diese beiden Umrechnungsmethoden gibt es
     601                 :            : // auch noch in tpsubt bzw. ueberall, wo StarCalc-Funktionen
     602                 :            : // auswaehlbar sind.
     603                 :            : 
     604                 :          0 : ScSubTotalFunc ScConsolidateDlg::LbPosToFunc( sal_uInt16 nPos )
     605                 :            : {
     606   [ #  #  #  #  :          0 :     switch ( nPos )
          #  #  #  #  #  
                   #  # ]
     607                 :            :     {
     608                 :          0 :         case  2:    return SUBTOTAL_FUNC_AVE;
     609                 :          0 :         case  6:    return SUBTOTAL_FUNC_CNT;
     610                 :          0 :         case  1:    return SUBTOTAL_FUNC_CNT2;
     611                 :          0 :         case  3:    return SUBTOTAL_FUNC_MAX;
     612                 :          0 :         case  4:    return SUBTOTAL_FUNC_MIN;
     613                 :          0 :         case  5:    return SUBTOTAL_FUNC_PROD;
     614                 :          0 :         case  7:    return SUBTOTAL_FUNC_STD;
     615                 :          0 :         case  8:    return SUBTOTAL_FUNC_STDP;
     616                 :          0 :         case  9:    return SUBTOTAL_FUNC_VAR;
     617                 :          0 :         case 10:    return SUBTOTAL_FUNC_VARP;
     618                 :            :         case  0:
     619                 :            :         default:
     620                 :          0 :             return SUBTOTAL_FUNC_SUM;
     621                 :            :     }
     622                 :            : }
     623                 :            : 
     624                 :            : 
     625                 :            : //----------------------------------------------------------------------------
     626                 :            : 
     627                 :          0 : sal_uInt16 ScConsolidateDlg::FuncToLbPos( ScSubTotalFunc eFunc )
     628                 :            : {
     629   [ #  #  #  #  :          0 :     switch ( eFunc )
          #  #  #  #  #  
                   #  # ]
     630                 :            :     {
     631                 :          0 :         case SUBTOTAL_FUNC_AVE:     return 2;
     632                 :          0 :         case SUBTOTAL_FUNC_CNT:     return 6;
     633                 :          0 :         case SUBTOTAL_FUNC_CNT2:    return 1;
     634                 :          0 :         case SUBTOTAL_FUNC_MAX:     return 3;
     635                 :          0 :         case SUBTOTAL_FUNC_MIN:     return 4;
     636                 :          0 :         case SUBTOTAL_FUNC_PROD:    return 5;
     637                 :          0 :         case SUBTOTAL_FUNC_STD:     return 7;
     638                 :          0 :         case SUBTOTAL_FUNC_STDP:    return 8;
     639                 :          0 :         case SUBTOTAL_FUNC_VAR:     return 9;
     640                 :          0 :         case SUBTOTAL_FUNC_VARP:    return 10;
     641                 :            :         case SUBTOTAL_FUNC_NONE:
     642                 :            :         case SUBTOTAL_FUNC_SUM:
     643                 :            :         default:
     644                 :          0 :             return 0;
     645                 :            :     }
     646                 :            : }
     647                 :            : 
     648                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10