LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/optdlg - tpcalc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 116 0.0 %
Date: 2013-07-09 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             : #include "tpcalc.hxx"
      38             : 
      39             : #include <math.h>
      40             : 
      41             : //========================================================================
      42             : 
      43           0 : ScTpCalcOptions::ScTpCalcOptions(Window* pParent, const SfxItemSet& rCoreAttrs)
      44             :     : SfxTabPage(pParent, "OptCalculatePage",
      45             :         "modules/scalc/ui/optcalculatepage.ui", rCoreAttrs)
      46             :     , pOldOptions(new ScDocOptions(
      47             :         ((const ScTpCalcItem&)rCoreAttrs.Get(
      48           0 :             GetWhich(SID_SCDOCOPTIONS))).GetDocOptions()))
      49           0 :     , pLocalOptions(new ScDocOptions)
      50           0 :     , nWhichCalc(GetWhich(SID_SCDOCOPTIONS))
      51             : {
      52           0 :     get(m_pBtnIterate, "iterate");
      53           0 :     get(m_pFtSteps, "stepsft");
      54           0 :     get(m_pEdSteps, "steps");
      55           0 :     get(m_pFtEps, "minchangeft");
      56           0 :     get(m_pEdEps, "minchange");
      57           0 :     get(m_pBtnDateStd, "datestd");
      58           0 :     get(m_pBtnDateSc10, "datesc10");
      59           0 :     get(m_pBtnDate1904, "date1904");
      60           0 :     get(m_pBtnCase, "case");
      61           0 :     get(m_pBtnCalc, "calc");
      62           0 :     get(m_pBtnMatch, "match");
      63           0 :     get(m_pBtnRegex, "regex");
      64           0 :     get(m_pBtnLookUp, "lookup");
      65           0 :     get(m_pBtnGeneralPrec, "generalprec");
      66           0 :     get(m_pFtPrec, "precft");
      67           0 :     get(m_pEdPrec, "prec");
      68           0 :     Init();
      69           0 :     SetExchangeSupport();
      70           0 : }
      71             : 
      72             : //-----------------------------------------------------------------------
      73             : 
      74           0 : ScTpCalcOptions::~ScTpCalcOptions()
      75             : {
      76           0 :     delete pOldOptions;
      77           0 :     delete pLocalOptions;
      78           0 : }
      79             : 
      80             : //-----------------------------------------------------------------------
      81             : 
      82           0 : void ScTpCalcOptions::Init()
      83             : {
      84           0 :     m_pBtnIterate->SetClickHdl( LINK( this, ScTpCalcOptions, CheckClickHdl ) );
      85           0 :     m_pBtnGeneralPrec->SetClickHdl( LINK(this, ScTpCalcOptions, CheckClickHdl) );
      86           0 :     m_pBtnDateStd->SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
      87           0 :     m_pBtnDateSc10->SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
      88           0 :     m_pBtnDate1904->SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
      89           0 : }
      90             : 
      91             : //-----------------------------------------------------------------------
      92             : 
      93           0 : SfxTabPage* ScTpCalcOptions::Create( Window* pParent, const SfxItemSet& rAttrSet )
      94             : {
      95           0 :     return ( new ScTpCalcOptions( pParent, rAttrSet ) );
      96             : }
      97             : 
      98             : //-----------------------------------------------------------------------
      99             : 
     100           0 : void ScTpCalcOptions::Reset( const SfxItemSet& /* rCoreAttrs */ )
     101             : {
     102             :     sal_uInt16  d,m,y;
     103             : 
     104           0 :     *pLocalOptions  = *pOldOptions;
     105             : 
     106           0 :     m_pBtnCase->Check( !pLocalOptions->IsIgnoreCase() );
     107           0 :     m_pBtnCalc->Check( pLocalOptions->IsCalcAsShown() );
     108           0 :     m_pBtnMatch->Check( pLocalOptions->IsMatchWholeCell() );
     109           0 :     m_pBtnRegex->Check( pLocalOptions->IsFormulaRegexEnabled() );
     110           0 :     m_pBtnLookUp->Check( pLocalOptions->IsLookUpColRowNames() );
     111           0 :     m_pBtnIterate->Check( pLocalOptions->IsIter() );
     112           0 :     m_pEdSteps->SetValue( pLocalOptions->GetIterCount() );
     113           0 :     m_pEdEps->SetValue( pLocalOptions->GetIterEps(), 6 );
     114             : 
     115           0 :     pLocalOptions->GetDate( d, m, y );
     116             : 
     117           0 :     switch ( y )
     118             :     {
     119             :         case 1899:
     120           0 :             m_pBtnDateStd->Check();
     121           0 :             break;
     122             :         case 1900:
     123           0 :             m_pBtnDateSc10->Check();
     124           0 :             break;
     125             :         case 1904:
     126           0 :             m_pBtnDate1904->Check();
     127           0 :             break;
     128             :     }
     129             : 
     130           0 :     sal_uInt16 nPrec = pLocalOptions->GetStdPrecision();
     131           0 :     if (nPrec == SvNumberFormatter::UNLIMITED_PRECISION)
     132             :     {
     133           0 :         m_pFtPrec->Disable();
     134           0 :         m_pEdPrec->Disable();
     135           0 :         m_pBtnGeneralPrec->Check(false);
     136             :     }
     137             :     else
     138             :     {
     139           0 :         m_pBtnGeneralPrec->Check();
     140           0 :         m_pFtPrec->Enable();
     141           0 :         m_pEdPrec->Enable();
     142           0 :         m_pEdPrec->SetValue(nPrec);
     143             :     }
     144             : 
     145           0 :     CheckClickHdl(m_pBtnIterate);
     146           0 : }
     147             : 
     148             : 
     149             : //-----------------------------------------------------------------------
     150             : 
     151           0 : sal_Bool ScTpCalcOptions::FillItemSet( SfxItemSet& rCoreAttrs )
     152             : {
     153             :     // alle weiteren Optionen werden in den Handlern aktualisiert
     154           0 :     pLocalOptions->SetIterCount( (sal_uInt16)m_pEdSteps->GetValue() );
     155           0 :     pLocalOptions->SetIgnoreCase( !m_pBtnCase->IsChecked() );
     156           0 :     pLocalOptions->SetCalcAsShown( m_pBtnCalc->IsChecked() );
     157           0 :     pLocalOptions->SetMatchWholeCell( m_pBtnMatch->IsChecked() );
     158           0 :     pLocalOptions->SetFormulaRegexEnabled( m_pBtnRegex->IsChecked() );
     159           0 :     pLocalOptions->SetLookUpColRowNames( m_pBtnLookUp->IsChecked() );
     160             : 
     161           0 :     if (m_pBtnGeneralPrec->IsChecked())
     162             :         pLocalOptions->SetStdPrecision(
     163           0 :             static_cast<sal_uInt16>(m_pEdPrec->GetValue()) );
     164             :     else
     165           0 :         pLocalOptions->SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION );
     166             : 
     167           0 :     if ( *pLocalOptions != *pOldOptions )
     168             :     {
     169           0 :         rCoreAttrs.Put( ScTpCalcItem( nWhichCalc, *pLocalOptions ) );
     170           0 :         return sal_True;
     171             :     }
     172             :     else
     173           0 :         return false;
     174             : }
     175             : 
     176             : //------------------------------------------------------------------------
     177             : 
     178           0 : int ScTpCalcOptions::DeactivatePage( SfxItemSet* pSetP )
     179             : {
     180           0 :     int nReturn = KEEP_PAGE;
     181             : 
     182             :     double fEps;
     183           0 :     if( m_pEdEps->GetValue( fEps ) && (fEps > 0.0) )
     184             :     {
     185           0 :         pLocalOptions->SetIterEps( fEps );
     186           0 :         nReturn = LEAVE_PAGE;
     187             :     }
     188             : 
     189           0 :     if ( nReturn == KEEP_PAGE )
     190             :     {
     191             :         ErrorBox( this,
     192             :                   WinBits( WB_OK | WB_DEF_OK ),
     193           0 :                   ScGlobal::GetRscString( STR_INVALID_EPS )
     194           0 :                 ).Execute();
     195             : 
     196           0 :         m_pEdEps->GrabFocus();
     197             :     }
     198           0 :     else if ( pSetP )
     199           0 :         FillItemSet( *pSetP );
     200             : 
     201           0 :     return nReturn;
     202             : }
     203             : 
     204             : //-----------------------------------------------------------------------
     205             : // Handler:
     206             : 
     207           0 : IMPL_LINK( ScTpCalcOptions, RadioClickHdl, RadioButton*, pBtn )
     208             : {
     209           0 :     if (pBtn == m_pBtnDateStd)
     210             :     {
     211           0 :         pLocalOptions->SetDate( 30, 12, 1899 );
     212             :     }
     213           0 :     else if (pBtn == m_pBtnDateSc10)
     214             :     {
     215           0 :         pLocalOptions->SetDate( 1, 1, 1900 );
     216             :     }
     217           0 :     else if (pBtn == m_pBtnDate1904)
     218             :     {
     219           0 :         pLocalOptions->SetDate( 1, 1, 1904 );
     220             :     }
     221             : 
     222           0 :     return 0;
     223             : }
     224             : 
     225             : //-----------------------------------------------------------------------
     226             : 
     227           0 : IMPL_LINK( ScTpCalcOptions, CheckClickHdl, CheckBox*, pBtn )
     228             : {
     229           0 :     if (pBtn == m_pBtnGeneralPrec)
     230             :     {
     231           0 :         if (pBtn->IsChecked())
     232             :         {
     233           0 :             m_pEdPrec->Enable();
     234           0 :             m_pFtPrec->Enable();
     235             :         }
     236             :         else
     237             :         {
     238           0 :             m_pEdPrec->Disable();
     239           0 :             m_pFtPrec->Disable();
     240             :         }
     241             :     }
     242           0 :     else if (pBtn == m_pBtnIterate)
     243             :     {
     244           0 :         if ( pBtn->IsChecked() )
     245             :         {
     246           0 :             pLocalOptions->SetIter( true );
     247           0 :             m_pFtSteps->Enable();  m_pEdSteps->Enable();
     248           0 :             m_pFtEps->Enable();  m_pEdEps->Enable();
     249             :         }
     250             :         else
     251             :         {
     252           0 :             pLocalOptions->SetIter( false );
     253           0 :             m_pFtSteps->Disable(); m_pEdSteps->Disable();
     254           0 :             m_pFtEps->Disable(); m_pEdEps->Disable();
     255             :         }
     256             :     }
     257             : 
     258           0 :     return 0;
     259           0 : }
     260             : 
     261             : 
     262             : 
     263             : 
     264             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10