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

Generated by: LCOV version 1.10