LCOV - code coverage report
Current view: top level - sc/source/ui/optdlg - tpcalc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 102 0.0 %
Date: 2012-08-25 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 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                 :            : #undef SC_DLLIMPLEMENTATION
      30                 :            : 
      31                 :            : //------------------------------------------------------------------
      32                 :            : 
      33                 :            : #include "scitems.hxx"
      34                 :            : #include <vcl/msgbox.hxx>
      35                 :            : 
      36                 :            : #include "global.hxx"
      37                 :            : #include "globstr.hrc"
      38                 :            : #include "uiitems.hxx"
      39                 :            : #include "docsh.hxx"
      40                 :            : #include "document.hxx"
      41                 :            : #include "docoptio.hxx"
      42                 :            : #include "scresid.hxx"
      43                 :            : #include "sc.hrc"       // -> Slot-IDs
      44                 :            : #include "optdlg.hrc"
      45                 :            : 
      46                 :            : #define _TPCALC_CXX
      47                 :            : #include "tpcalc.hxx"
      48                 :            : #undef _TPCALC_CXX
      49                 :            : 
      50                 :            : #include <math.h>
      51                 :            : 
      52                 :            : //========================================================================
      53                 :            : 
      54                 :          0 : ScTpCalcOptions::ScTpCalcOptions( Window*           pParent,
      55                 :            :                                   const SfxItemSet& rCoreAttrs )
      56                 :            : 
      57                 :            :     :   SfxTabPage      ( pParent,
      58                 :            :                           ScResId( RID_SCPAGE_CALC ),
      59                 :            :                           rCoreAttrs ),
      60                 :            : 
      61                 :            :         aGbZRefs        ( this, ScResId( GB_ZREFS ) ),
      62                 :            :         aBtnIterate     ( this, ScResId( BTN_ITERATE ) ),
      63                 :            :         aFtSteps        ( this, ScResId( FT_STEPS ) ),
      64                 :            :         aEdSteps        ( this, ScResId( ED_STEPS ) ),
      65                 :            :         aFtEps          ( this, ScResId( FT_EPS ) ),
      66                 :            :         aEdEps          ( this, ScResId( ED_EPS ) ),
      67                 :            :         aSeparatorFL    ( this, ScResId( FL_SEPARATOR ) ),
      68                 :            :         aGbDate         ( this, ScResId( GB_DATE ) ),
      69                 :            :         aBtnDateStd     ( this, ScResId( BTN_DATESTD ) ),
      70                 :            :         aBtnDateSc10    ( this, ScResId( BTN_DATESC10 ) ),
      71                 :            :         aBtnDate1904    ( this, ScResId( BTN_DATE1904 ) ),
      72                 :            :         aBtnCase        ( this, ScResId( BTN_CASE ) ),
      73                 :            :         aBtnCalc        ( this, ScResId( BTN_CALC ) ),
      74                 :            :         aBtnMatch       ( this, ScResId( BTN_MATCH ) ),
      75                 :            :         aBtnRegex       ( this, ScResId( BTN_REGEX ) ),
      76                 :            :         aBtnLookUp      ( this, ScResId( BTN_LOOKUP ) ),
      77                 :            :         aBtnGeneralPrec ( this, ScResId( BTN_GENERAL_PREC ) ),
      78                 :            :         aFtPrec         ( this, ScResId( FT_PREC ) ),
      79                 :            :         aEdPrec         ( this, ScResId( ED_PREC ) ),
      80                 :            :         pOldOptions     ( new ScDocOptions(
      81                 :            :                             ((const ScTpCalcItem&)rCoreAttrs.Get(
      82                 :          0 :                                 GetWhich( SID_SCDOCOPTIONS ))).
      83                 :          0 :                                     GetDocOptions() ) ),
      84                 :          0 :         pLocalOptions   ( new ScDocOptions ),
      85                 :          0 :         nWhichCalc      ( GetWhich( SID_SCDOCOPTIONS ) )
      86                 :            : {
      87                 :          0 :     aSeparatorFL.SetStyle( aSeparatorFL.GetStyle() | WB_VERT );
      88                 :          0 :     Init();
      89                 :          0 :     FreeResource();
      90                 :          0 :     SetExchangeSupport();
      91                 :          0 : }
      92                 :            : 
      93                 :            : //-----------------------------------------------------------------------
      94                 :            : 
      95                 :          0 : ScTpCalcOptions::~ScTpCalcOptions()
      96                 :            : {
      97                 :          0 :     delete pOldOptions;
      98                 :          0 :     delete pLocalOptions;
      99                 :          0 : }
     100                 :            : 
     101                 :            : //-----------------------------------------------------------------------
     102                 :            : 
     103                 :          0 : void ScTpCalcOptions::Init()
     104                 :            : {
     105                 :          0 :     aBtnIterate .SetClickHdl( LINK( this, ScTpCalcOptions, CheckClickHdl ) );
     106                 :          0 :     aBtnGeneralPrec.SetClickHdl( LINK(this, ScTpCalcOptions, CheckClickHdl) );
     107                 :          0 :     aBtnDateStd .SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
     108                 :          0 :     aBtnDateSc10.SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
     109                 :          0 :     aBtnDate1904.SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
     110                 :          0 : }
     111                 :            : 
     112                 :            : //-----------------------------------------------------------------------
     113                 :            : 
     114                 :          0 : SfxTabPage* ScTpCalcOptions::Create( Window* pParent, const SfxItemSet& rAttrSet )
     115                 :            : {
     116                 :          0 :     return ( new ScTpCalcOptions( pParent, rAttrSet ) );
     117                 :            : }
     118                 :            : 
     119                 :            : //-----------------------------------------------------------------------
     120                 :            : 
     121                 :          0 : void ScTpCalcOptions::Reset( const SfxItemSet& /* rCoreAttrs */ )
     122                 :            : {
     123                 :            :     sal_uInt16  d,m,y;
     124                 :            : 
     125                 :          0 :     *pLocalOptions  = *pOldOptions;
     126                 :            : 
     127                 :          0 :     aBtnCase   .Check( !pLocalOptions->IsIgnoreCase() );
     128                 :          0 :     aBtnCalc   .Check( pLocalOptions->IsCalcAsShown() );
     129                 :          0 :     aBtnMatch  .Check( pLocalOptions->IsMatchWholeCell() );
     130                 :          0 :     aBtnRegex  .Check( pLocalOptions->IsFormulaRegexEnabled() );
     131                 :          0 :     aBtnLookUp .Check( pLocalOptions->IsLookUpColRowNames() );
     132                 :          0 :     aBtnIterate.Check( pLocalOptions->IsIter() );
     133                 :          0 :     aEdSteps   .SetValue( pLocalOptions->GetIterCount() );
     134                 :          0 :     aEdEps     .SetValue( pLocalOptions->GetIterEps(), 6 );
     135                 :            : 
     136                 :          0 :     pLocalOptions->GetDate( d, m, y );
     137                 :            : 
     138                 :          0 :     switch ( y )
     139                 :            :     {
     140                 :            :         case 1899:
     141                 :          0 :             aBtnDateStd.Check();
     142                 :          0 :             break;
     143                 :            :         case 1900:
     144                 :          0 :             aBtnDateSc10.Check();
     145                 :          0 :             break;
     146                 :            :         case 1904:
     147                 :          0 :             aBtnDate1904.Check();
     148                 :          0 :             break;
     149                 :            :     }
     150                 :            : 
     151                 :          0 :     sal_uInt16 nPrec = pLocalOptions->GetStdPrecision();
     152                 :          0 :     if (nPrec == SvNumberFormatter::UNLIMITED_PRECISION)
     153                 :            :     {
     154                 :          0 :         aFtPrec.Disable();
     155                 :          0 :         aEdPrec.Disable();
     156                 :          0 :         aBtnGeneralPrec.Check(false);
     157                 :            :     }
     158                 :            :     else
     159                 :            :     {
     160                 :          0 :         aBtnGeneralPrec.Check();
     161                 :          0 :         aFtPrec.Enable();
     162                 :          0 :         aEdPrec.Enable();
     163                 :          0 :         aEdPrec.SetValue(nPrec);
     164                 :            :     }
     165                 :            : 
     166                 :          0 :     CheckClickHdl( &aBtnIterate );
     167                 :          0 : }
     168                 :            : 
     169                 :            : 
     170                 :            : //-----------------------------------------------------------------------
     171                 :            : 
     172                 :          0 : sal_Bool ScTpCalcOptions::FillItemSet( SfxItemSet& rCoreAttrs )
     173                 :            : {
     174                 :            :     // alle weiteren Optionen werden in den Handlern aktualisiert
     175                 :          0 :     pLocalOptions->SetIterCount( (sal_uInt16)aEdSteps.GetValue() );
     176                 :          0 :     pLocalOptions->SetIgnoreCase( !aBtnCase.IsChecked() );
     177                 :          0 :     pLocalOptions->SetCalcAsShown( aBtnCalc.IsChecked() );
     178                 :          0 :     pLocalOptions->SetMatchWholeCell( aBtnMatch.IsChecked() );
     179                 :          0 :     pLocalOptions->SetFormulaRegexEnabled( aBtnRegex.IsChecked() );
     180                 :          0 :     pLocalOptions->SetLookUpColRowNames( aBtnLookUp.IsChecked() );
     181                 :            : 
     182                 :          0 :     if (aBtnGeneralPrec.IsChecked())
     183                 :            :         pLocalOptions->SetStdPrecision(
     184                 :          0 :             static_cast<sal_uInt16>(aEdPrec.GetValue()) );
     185                 :            :     else
     186                 :          0 :         pLocalOptions->SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION );
     187                 :            : 
     188                 :          0 :     if ( *pLocalOptions != *pOldOptions )
     189                 :            :     {
     190                 :          0 :         rCoreAttrs.Put( ScTpCalcItem( nWhichCalc, *pLocalOptions ) );
     191                 :          0 :         return sal_True;
     192                 :            :     }
     193                 :            :     else
     194                 :          0 :         return false;
     195                 :            : }
     196                 :            : 
     197                 :            : //------------------------------------------------------------------------
     198                 :            : 
     199                 :          0 : int ScTpCalcOptions::DeactivatePage( SfxItemSet* pSetP )
     200                 :            : {
     201                 :          0 :     int nReturn = KEEP_PAGE;
     202                 :            : 
     203                 :            :     double fEps;
     204                 :          0 :     if( aEdEps.GetValue( fEps ) && (fEps > 0.0) )
     205                 :            :     {
     206                 :          0 :         pLocalOptions->SetIterEps( fEps );
     207                 :          0 :         nReturn = LEAVE_PAGE;
     208                 :            :     }
     209                 :            : 
     210                 :          0 :     if ( nReturn == KEEP_PAGE )
     211                 :            :     {
     212                 :            :         ErrorBox( this,
     213                 :            :                   WinBits( WB_OK | WB_DEF_OK ),
     214                 :          0 :                   ScGlobal::GetRscString( STR_INVALID_EPS )
     215                 :          0 :                 ).Execute();
     216                 :            : 
     217                 :          0 :         aEdEps.GrabFocus();
     218                 :            :     }
     219                 :          0 :     else if ( pSetP )
     220                 :          0 :         FillItemSet( *pSetP );
     221                 :            : 
     222                 :          0 :     return nReturn;
     223                 :            : }
     224                 :            : 
     225                 :            : //-----------------------------------------------------------------------
     226                 :            : // Handler:
     227                 :            : 
     228                 :          0 : IMPL_LINK( ScTpCalcOptions, RadioClickHdl, RadioButton*, pBtn )
     229                 :            : {
     230                 :          0 :     if ( pBtn == &aBtnDateStd )
     231                 :            :     {
     232                 :          0 :         pLocalOptions->SetDate( 30, 12, 1899 );
     233                 :            :     }
     234                 :          0 :     else if ( pBtn == &aBtnDateSc10 )
     235                 :            :     {
     236                 :          0 :         pLocalOptions->SetDate( 1, 1, 1900 );
     237                 :            :     }
     238                 :          0 :     else if ( pBtn == &aBtnDate1904 )
     239                 :            :     {
     240                 :          0 :         pLocalOptions->SetDate( 1, 1, 1904 );
     241                 :            :     }
     242                 :            : 
     243                 :          0 :     return 0;
     244                 :            : }
     245                 :            : 
     246                 :            : //-----------------------------------------------------------------------
     247                 :            : 
     248                 :          0 : IMPL_LINK( ScTpCalcOptions, CheckClickHdl, CheckBox*, pBtn )
     249                 :            : {
     250                 :          0 :     if (pBtn == &aBtnGeneralPrec)
     251                 :            :     {
     252                 :          0 :         if (pBtn->IsChecked())
     253                 :            :         {
     254                 :          0 :             aEdPrec.Enable();
     255                 :          0 :             aFtPrec.Enable();
     256                 :            :         }
     257                 :            :         else
     258                 :            :         {
     259                 :          0 :             aEdPrec.Disable();
     260                 :          0 :             aFtPrec.Disable();
     261                 :            :         }
     262                 :            :     }
     263                 :          0 :     else if (pBtn == &aBtnIterate)
     264                 :            :     {
     265                 :          0 :         if ( pBtn->IsChecked() )
     266                 :            :         {
     267                 :          0 :             pLocalOptions->SetIter( sal_True );
     268                 :          0 :             aFtSteps.Enable();  aEdSteps.Enable();
     269                 :          0 :             aFtEps  .Enable();  aEdEps  .Enable();
     270                 :            :         }
     271                 :            :         else
     272                 :            :         {
     273                 :          0 :             pLocalOptions->SetIter( false );
     274                 :          0 :             aFtSteps.Disable(); aEdSteps.Disable();
     275                 :          0 :             aFtEps  .Disable(); aEdEps  .Disable();
     276                 :            :         }
     277                 :            :     }
     278                 :            : 
     279                 :          0 :     return 0;
     280                 :            : }
     281                 :            : 
     282                 :            : 
     283                 :            : 
     284                 :            : 
     285                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10