LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/optdlg - tpcalc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 103 0.0 %
Date: 2012-12-17 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #undef SC_DLLIMPLEMENTATION
      21             : 
      22             : //------------------------------------------------------------------
      23             : 
      24             : #include "scitems.hxx"
      25             : #include <vcl/msgbox.hxx>
      26             : 
      27             : #include "global.hxx"
      28             : #include "globstr.hrc"
      29             : #include "uiitems.hxx"
      30             : #include "docsh.hxx"
      31             : #include "document.hxx"
      32             : #include "docoptio.hxx"
      33             : #include "scresid.hxx"
      34             : #include "sc.hrc"       // -> Slot-IDs
      35             : #include "optdlg.hrc"
      36             : 
      37             : #define _TPCALC_CXX
      38             : #include "tpcalc.hxx"
      39             : #undef _TPCALC_CXX
      40             : 
      41             : #include <math.h>
      42             : 
      43             : //========================================================================
      44             : 
      45           0 : ScTpCalcOptions::ScTpCalcOptions( Window*           pParent,
      46             :                                   const SfxItemSet& rCoreAttrs )
      47             : 
      48             :     :   SfxTabPage      ( pParent,
      49             :                           ScResId( RID_SCPAGE_CALC ),
      50             :                           rCoreAttrs ),
      51             : 
      52             :         aGbZRefs        ( this, ScResId( GB_ZREFS ) ),
      53             :         aBtnIterate     ( this, ScResId( BTN_ITERATE ) ),
      54             :         aFtSteps        ( this, ScResId( FT_STEPS ) ),
      55             :         aEdSteps        ( this, ScResId( ED_STEPS ) ),
      56             :         aFtEps          ( this, ScResId( FT_EPS ) ),
      57             :         aEdEps          ( this, ScResId( ED_EPS ) ),
      58             :         aSeparatorFL    ( this, ScResId( FL_SEPARATOR ) ),
      59             :         aGbDate         ( this, ScResId( GB_DATE ) ),
      60             :         aBtnDateStd     ( this, ScResId( BTN_DATESTD ) ),
      61             :         aBtnDateSc10    ( this, ScResId( BTN_DATESC10 ) ),
      62             :         aBtnDate1904    ( this, ScResId( BTN_DATE1904 ) ),
      63             :         aBtnCase        ( this, ScResId( BTN_CASE ) ),
      64             :         aBtnCalc        ( this, ScResId( BTN_CALC ) ),
      65             :         aBtnMatch       ( this, ScResId( BTN_MATCH ) ),
      66             :         aBtnRegex       ( this, ScResId( BTN_REGEX ) ),
      67             :         aBtnLookUp      ( this, ScResId( BTN_LOOKUP ) ),
      68             :         aBtnGeneralPrec ( this, ScResId( BTN_GENERAL_PREC ) ),
      69             :         aFtPrec         ( this, ScResId( FT_PREC ) ),
      70             :         aEdPrec         ( this, ScResId( ED_PREC ) ),
      71             :         pOldOptions     ( new ScDocOptions(
      72             :                             ((const ScTpCalcItem&)rCoreAttrs.Get(
      73           0 :                                 GetWhich( SID_SCDOCOPTIONS ))).
      74           0 :                                     GetDocOptions() ) ),
      75           0 :         pLocalOptions   ( new ScDocOptions ),
      76           0 :         nWhichCalc      ( GetWhich( SID_SCDOCOPTIONS ) )
      77             : {
      78           0 :     aSeparatorFL.SetStyle( aSeparatorFL.GetStyle() | WB_VERT );
      79           0 :     Init();
      80           0 :     FreeResource();
      81           0 :     SetExchangeSupport();
      82           0 : }
      83             : 
      84             : //-----------------------------------------------------------------------
      85             : 
      86           0 : ScTpCalcOptions::~ScTpCalcOptions()
      87             : {
      88           0 :     delete pOldOptions;
      89           0 :     delete pLocalOptions;
      90           0 : }
      91             : 
      92             : //-----------------------------------------------------------------------
      93             : 
      94           0 : void ScTpCalcOptions::Init()
      95             : {
      96           0 :     aBtnIterate .SetClickHdl( LINK( this, ScTpCalcOptions, CheckClickHdl ) );
      97           0 :     aBtnGeneralPrec.SetClickHdl( LINK(this, ScTpCalcOptions, CheckClickHdl) );
      98           0 :     aBtnDateStd .SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
      99           0 :     aBtnDateSc10.SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
     100           0 :     aBtnDate1904.SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
     101           0 : }
     102             : 
     103             : //-----------------------------------------------------------------------
     104             : 
     105           0 : SfxTabPage* ScTpCalcOptions::Create( Window* pParent, const SfxItemSet& rAttrSet )
     106             : {
     107           0 :     return ( new ScTpCalcOptions( pParent, rAttrSet ) );
     108             : }
     109             : 
     110             : //-----------------------------------------------------------------------
     111             : 
     112           0 : void ScTpCalcOptions::Reset( const SfxItemSet& /* rCoreAttrs */ )
     113             : {
     114             :     sal_uInt16  d,m,y;
     115             : 
     116           0 :     *pLocalOptions  = *pOldOptions;
     117             : 
     118           0 :     aBtnCase   .Check( !pLocalOptions->IsIgnoreCase() );
     119           0 :     aBtnCalc   .Check( pLocalOptions->IsCalcAsShown() );
     120           0 :     aBtnMatch  .Check( pLocalOptions->IsMatchWholeCell() );
     121           0 :     aBtnRegex  .Check( pLocalOptions->IsFormulaRegexEnabled() );
     122           0 :     aBtnLookUp .Check( pLocalOptions->IsLookUpColRowNames() );
     123           0 :     aBtnIterate.Check( pLocalOptions->IsIter() );
     124           0 :     aEdSteps   .SetValue( pLocalOptions->GetIterCount() );
     125           0 :     aEdEps     .SetValue( pLocalOptions->GetIterEps(), 6 );
     126             : 
     127           0 :     pLocalOptions->GetDate( d, m, y );
     128             : 
     129           0 :     switch ( y )
     130             :     {
     131             :         case 1899:
     132           0 :             aBtnDateStd.Check();
     133           0 :             break;
     134             :         case 1900:
     135           0 :             aBtnDateSc10.Check();
     136           0 :             break;
     137             :         case 1904:
     138           0 :             aBtnDate1904.Check();
     139           0 :             break;
     140             :     }
     141             : 
     142           0 :     sal_uInt16 nPrec = pLocalOptions->GetStdPrecision();
     143           0 :     if (nPrec == SvNumberFormatter::UNLIMITED_PRECISION)
     144             :     {
     145           0 :         aFtPrec.Disable();
     146           0 :         aEdPrec.Disable();
     147           0 :         aBtnGeneralPrec.Check(false);
     148             :     }
     149             :     else
     150             :     {
     151           0 :         aBtnGeneralPrec.Check();
     152           0 :         aFtPrec.Enable();
     153           0 :         aEdPrec.Enable();
     154           0 :         aEdPrec.SetValue(nPrec);
     155             :     }
     156             : 
     157           0 :     CheckClickHdl( &aBtnIterate );
     158           0 : }
     159             : 
     160             : 
     161             : //-----------------------------------------------------------------------
     162             : 
     163           0 : sal_Bool ScTpCalcOptions::FillItemSet( SfxItemSet& rCoreAttrs )
     164             : {
     165             :     // alle weiteren Optionen werden in den Handlern aktualisiert
     166           0 :     pLocalOptions->SetIterCount( (sal_uInt16)aEdSteps.GetValue() );
     167           0 :     pLocalOptions->SetIgnoreCase( !aBtnCase.IsChecked() );
     168           0 :     pLocalOptions->SetCalcAsShown( aBtnCalc.IsChecked() );
     169           0 :     pLocalOptions->SetMatchWholeCell( aBtnMatch.IsChecked() );
     170           0 :     pLocalOptions->SetFormulaRegexEnabled( aBtnRegex.IsChecked() );
     171           0 :     pLocalOptions->SetLookUpColRowNames( aBtnLookUp.IsChecked() );
     172             : 
     173           0 :     if (aBtnGeneralPrec.IsChecked())
     174             :         pLocalOptions->SetStdPrecision(
     175           0 :             static_cast<sal_uInt16>(aEdPrec.GetValue()) );
     176             :     else
     177           0 :         pLocalOptions->SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION );
     178             : 
     179           0 :     if ( *pLocalOptions != *pOldOptions )
     180             :     {
     181           0 :         rCoreAttrs.Put( ScTpCalcItem( nWhichCalc, *pLocalOptions ) );
     182           0 :         return sal_True;
     183             :     }
     184             :     else
     185           0 :         return false;
     186             : }
     187             : 
     188             : //------------------------------------------------------------------------
     189             : 
     190           0 : int ScTpCalcOptions::DeactivatePage( SfxItemSet* pSetP )
     191             : {
     192           0 :     int nReturn = KEEP_PAGE;
     193             : 
     194             :     double fEps;
     195           0 :     if( aEdEps.GetValue( fEps ) && (fEps > 0.0) )
     196             :     {
     197           0 :         pLocalOptions->SetIterEps( fEps );
     198           0 :         nReturn = LEAVE_PAGE;
     199             :     }
     200             : 
     201           0 :     if ( nReturn == KEEP_PAGE )
     202             :     {
     203             :         ErrorBox( this,
     204             :                   WinBits( WB_OK | WB_DEF_OK ),
     205           0 :                   ScGlobal::GetRscString( STR_INVALID_EPS )
     206           0 :                 ).Execute();
     207             : 
     208           0 :         aEdEps.GrabFocus();
     209             :     }
     210           0 :     else if ( pSetP )
     211           0 :         FillItemSet( *pSetP );
     212             : 
     213           0 :     return nReturn;
     214             : }
     215             : 
     216             : //-----------------------------------------------------------------------
     217             : // Handler:
     218             : 
     219           0 : IMPL_LINK( ScTpCalcOptions, RadioClickHdl, RadioButton*, pBtn )
     220             : {
     221           0 :     if ( pBtn == &aBtnDateStd )
     222             :     {
     223           0 :         pLocalOptions->SetDate( 30, 12, 1899 );
     224             :     }
     225           0 :     else if ( pBtn == &aBtnDateSc10 )
     226             :     {
     227           0 :         pLocalOptions->SetDate( 1, 1, 1900 );
     228             :     }
     229           0 :     else if ( pBtn == &aBtnDate1904 )
     230             :     {
     231           0 :         pLocalOptions->SetDate( 1, 1, 1904 );
     232             :     }
     233             : 
     234           0 :     return 0;
     235             : }
     236             : 
     237             : //-----------------------------------------------------------------------
     238             : 
     239           0 : IMPL_LINK( ScTpCalcOptions, CheckClickHdl, CheckBox*, pBtn )
     240             : {
     241           0 :     if (pBtn == &aBtnGeneralPrec)
     242             :     {
     243           0 :         if (pBtn->IsChecked())
     244             :         {
     245           0 :             aEdPrec.Enable();
     246           0 :             aFtPrec.Enable();
     247             :         }
     248             :         else
     249             :         {
     250           0 :             aEdPrec.Disable();
     251           0 :             aFtPrec.Disable();
     252             :         }
     253             :     }
     254           0 :     else if (pBtn == &aBtnIterate)
     255             :     {
     256           0 :         if ( pBtn->IsChecked() )
     257             :         {
     258           0 :             pLocalOptions->SetIter( sal_True );
     259           0 :             aFtSteps.Enable();  aEdSteps.Enable();
     260           0 :             aFtEps  .Enable();  aEdEps  .Enable();
     261             :         }
     262             :         else
     263             :         {
     264           0 :             pLocalOptions->SetIter( false );
     265           0 :             aFtSteps.Disable(); aEdSteps.Disable();
     266           0 :             aFtEps  .Disable(); aEdEps  .Disable();
     267             :         }
     268             :     }
     269             : 
     270           0 :     return 0;
     271           0 : }
     272             : 
     273             : 
     274             : 
     275             : 
     276             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10