LCOV - code coverage report
Current view: top level - sc/source/ui/cctrl - editfield.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 20 0.0 %
Date: 2014-04-14 Functions: 0 6 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             : 
      21             : #ifdef SC_DLLIMPLEMENTATION
      22             : #undef SC_DLLIMPLEMENTATION
      23             : #endif
      24             : #include "editfield.hxx"
      25             : #include <comphelper/string.hxx>
      26             : #include <rtl/math.hxx>
      27             : #include <unotools/localedatawrapper.hxx>
      28             : #include <vcl/builder.hxx>
      29             : #include "global.hxx"
      30             : 
      31             : namespace {
      32             : 
      33           0 : sal_Unicode lclGetDecSep()
      34             : {
      35           0 :     return ScGlobal::GetpLocaleData()->getNumDecimalSep()[0];
      36             : }
      37             : 
      38           0 : sal_Unicode lclGetGroupSep()
      39             : {
      40           0 :     return ScGlobal::GetpLocaleData()->getNumThousandSep()[0];
      41             : }
      42             : 
      43             : } // namespace
      44             : 
      45           0 : ScDoubleField::ScDoubleField( Window* pParent, WinBits nStyle ) :
      46           0 :     Edit( pParent, nStyle )
      47             : {
      48           0 : }
      49             : 
      50           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeScDoubleField(Window *pParent, VclBuilder::stringmap &rMap)
      51             : {
      52           0 :     VclBuilder::ensureDefaultWidthChars(rMap);
      53           0 :     return new ScDoubleField(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
      54             : }
      55             : 
      56           0 : bool ScDoubleField::GetValue( double& rfValue ) const
      57             : {
      58           0 :     OUString aStr(comphelper::string::strip(GetText(), ' '));
      59           0 :     bool bOk = !aStr.isEmpty();
      60           0 :     if( bOk )
      61             :     {
      62             :         rtl_math_ConversionStatus eStatus;
      63             :         sal_Int32 nEnd;
      64           0 :         rfValue = rtl::math::stringToDouble( aStr, lclGetDecSep(), lclGetGroupSep(), &eStatus, &nEnd );
      65           0 :         bOk = (eStatus == rtl_math_ConversionStatus_Ok) && (nEnd == aStr.getLength() );
      66             :     }
      67           0 :     return bOk;
      68             : }
      69             : 
      70           0 : void ScDoubleField::SetValue( double fValue, sal_Int32 nDecPlaces, bool bEraseTrailingDecZeros )
      71             : {
      72             :     SetText( ::rtl::math::doubleToUString( fValue, rtl_math_StringFormat_G,
      73           0 :         nDecPlaces, lclGetDecSep(), bEraseTrailingDecZeros ) );
      74           0 : }
      75             : 
      76             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10