fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / cctrl / editfield.cxx
blob13419e8a91b49ff1d9615659c3dcaca04cd61281
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifdef SC_DLLIMPLEMENTATION
21 #undef SC_DLLIMPLEMENTATION
22 #endif
23 #include "editfield.hxx"
24 #include <comphelper/string.hxx>
25 #include <rtl/math.hxx>
26 #include <unotools/localedatawrapper.hxx>
27 #include <vcl/builderfactory.hxx>
28 #include "global.hxx"
30 namespace {
32 sal_Unicode lclGetDecSep()
34 return ScGlobal::GetpLocaleData()->getNumDecimalSep()[0];
37 sal_Unicode lclGetGroupSep()
39 return ScGlobal::GetpLocaleData()->getNumThousandSep()[0];
42 } // namespace
44 ScDoubleField::ScDoubleField( vcl::Window* pParent, WinBits nStyle ) :
45 Edit( pParent, nStyle )
49 VCL_BUILDER_DECL_FACTORY(ScDoubleField)
51 VclBuilder::ensureDefaultWidthChars(rMap);
52 rRet = VclPtr<ScDoubleField>::Create(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK);
55 bool ScDoubleField::GetValue( double& rfValue ) const
57 OUString aStr(comphelper::string::strip(GetText(), ' '));
58 bool bOk = !aStr.isEmpty();
59 if( bOk )
61 rtl_math_ConversionStatus eStatus;
62 sal_Int32 nEnd;
63 rfValue = rtl::math::stringToDouble( aStr, lclGetDecSep(), lclGetGroupSep(), &eStatus, &nEnd );
64 bOk = (eStatus == rtl_math_ConversionStatus_Ok) && (nEnd == aStr.getLength() );
66 return bOk;
69 void ScDoubleField::SetValue( double fValue, sal_Int32 nDecPlaces, bool bEraseTrailingDecZeros )
71 SetText( ::rtl::math::doubleToUString( fValue, rtl_math_StringFormat_G,
72 nDecPlaces, lclGetDecSep(), bEraseTrailingDecZeros ) );
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */