1*1f882ec4SArmin Le Grand /************************************************************** 2*1f882ec4SArmin Le Grand * 3*1f882ec4SArmin Le Grand * Licensed to the Apache Software Foundation (ASF) under one 4*1f882ec4SArmin Le Grand * or more contributor license agreements. See the NOTICE file 5*1f882ec4SArmin Le Grand * distributed with this work for additional information 6*1f882ec4SArmin Le Grand * regarding copyright ownership. The ASF licenses this file 7*1f882ec4SArmin Le Grand * to you under the Apache License, Version 2.0 (the 8*1f882ec4SArmin Le Grand * "License"); you may not use this file except in compliance 9*1f882ec4SArmin Le Grand * with the License. You may obtain a copy of the License at 10*1f882ec4SArmin Le Grand * 11*1f882ec4SArmin Le Grand * http://www.apache.org/licenses/LICENSE-2.0 12*1f882ec4SArmin Le Grand * 13*1f882ec4SArmin Le Grand * Unless required by applicable law or agreed to in writing, 14*1f882ec4SArmin Le Grand * software distributed under the License is distributed on an 15*1f882ec4SArmin Le Grand * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*1f882ec4SArmin Le Grand * KIND, either express or implied. See the License for the 17*1f882ec4SArmin Le Grand * specific language governing permissions and limitations 18*1f882ec4SArmin Le Grand * under the License. 19*1f882ec4SArmin Le Grand * 20*1f882ec4SArmin Le Grand *************************************************************/ 21*1f882ec4SArmin Le Grand 22*1f882ec4SArmin Le Grand #ifndef _STRINGCONVERSIONTOOLS_HXX 23*1f882ec4SArmin Le Grand #define _STRINGCONVERSIONTOOLS_HXX 24*1f882ec4SArmin Le Grand 25*1f882ec4SArmin Le Grand #include <sal/types.h> 26*1f882ec4SArmin Le Grand #include <rtl/ustring.hxx> 27*1f882ec4SArmin Le Grand #include <rtl/ustrbuf.hxx> 28*1f882ec4SArmin Le Grand 29*1f882ec4SArmin Le Grand namespace basegfx 30*1f882ec4SArmin Le Grand { 31*1f882ec4SArmin Le Grand namespace internal 32*1f882ec4SArmin Le Grand { 33*1f882ec4SArmin Le Grand void lcl_skipSpaces(sal_Int32& io_rPos, 34*1f882ec4SArmin Le Grand const ::rtl::OUString& rStr, 35*1f882ec4SArmin Le Grand const sal_Int32 nLen); 36*1f882ec4SArmin Le Grand 37*1f882ec4SArmin Le Grand void lcl_skipSpacesAndCommas(sal_Int32& io_rPos, 38*1f882ec4SArmin Le Grand const ::rtl::OUString& rStr, 39*1f882ec4SArmin Le Grand const sal_Int32 nLen); 40*1f882ec4SArmin Le Grand lcl_isOnNumberChar(const sal_Unicode aChar,bool bSignAllowed=true)41*1f882ec4SArmin Le Grand inline bool lcl_isOnNumberChar(const sal_Unicode aChar, bool bSignAllowed = true) 42*1f882ec4SArmin Le Grand { 43*1f882ec4SArmin Le Grand const bool bPredicate( (sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar) 44*1f882ec4SArmin Le Grand || (bSignAllowed && sal_Unicode('+') == aChar) 45*1f882ec4SArmin Le Grand || (bSignAllowed && sal_Unicode('-') == aChar) ); 46*1f882ec4SArmin Le Grand 47*1f882ec4SArmin Le Grand return bPredicate; 48*1f882ec4SArmin Le Grand } 49*1f882ec4SArmin Le Grand lcl_isOnNumberChar(const::rtl::OUString & rStr,const sal_Int32 nPos,bool bSignAllowed=true)50*1f882ec4SArmin Le Grand inline bool lcl_isOnNumberChar(const ::rtl::OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true) 51*1f882ec4SArmin Le Grand { 52*1f882ec4SArmin Le Grand return lcl_isOnNumberChar(rStr[nPos], 53*1f882ec4SArmin Le Grand bSignAllowed); 54*1f882ec4SArmin Le Grand } 55*1f882ec4SArmin Le Grand 56*1f882ec4SArmin Le Grand bool lcl_getDoubleChar(double& o_fRetval, 57*1f882ec4SArmin Le Grand sal_Int32& io_rPos, 58*1f882ec4SArmin Le Grand const ::rtl::OUString& rStr); 59*1f882ec4SArmin Le Grand 60*1f882ec4SArmin Le Grand bool lcl_importDoubleAndSpaces( double& o_fRetval, 61*1f882ec4SArmin Le Grand sal_Int32& io_rPos, 62*1f882ec4SArmin Le Grand const ::rtl::OUString& rStr, 63*1f882ec4SArmin Le Grand const sal_Int32 nLen ); 64*1f882ec4SArmin Le Grand 65*1f882ec4SArmin Le Grand bool lcl_importNumberAndSpaces(sal_Int32& o_nRetval, 66*1f882ec4SArmin Le Grand sal_Int32& io_rPos, 67*1f882ec4SArmin Le Grand const ::rtl::OUString& rStr, 68*1f882ec4SArmin Le Grand const sal_Int32 nLen); 69*1f882ec4SArmin Le Grand 70*1f882ec4SArmin Le Grand void lcl_skipNumber(sal_Int32& io_rPos, 71*1f882ec4SArmin Le Grand const ::rtl::OUString& rStr, 72*1f882ec4SArmin Le Grand const sal_Int32 nLen); 73*1f882ec4SArmin Le Grand 74*1f882ec4SArmin Le Grand void lcl_skipDouble(sal_Int32& io_rPos, 75*1f882ec4SArmin Le Grand const ::rtl::OUString& rStr); 76*1f882ec4SArmin Le Grand lcl_skipNumberAndSpacesAndCommas(sal_Int32 & io_rPos,const::rtl::OUString & rStr,const sal_Int32 nLen)77*1f882ec4SArmin Le Grand inline void lcl_skipNumberAndSpacesAndCommas(sal_Int32& io_rPos, 78*1f882ec4SArmin Le Grand const ::rtl::OUString& rStr, 79*1f882ec4SArmin Le Grand const sal_Int32 nLen) 80*1f882ec4SArmin Le Grand { 81*1f882ec4SArmin Le Grand lcl_skipNumber(io_rPos, rStr, nLen); 82*1f882ec4SArmin Le Grand lcl_skipSpacesAndCommas(io_rPos, rStr, nLen); 83*1f882ec4SArmin Le Grand } 84*1f882ec4SArmin Le Grand 85*1f882ec4SArmin Le Grand // #100617# Allow to skip doubles, too. lcl_skipDoubleAndSpacesAndCommas(sal_Int32 & io_rPos,const::rtl::OUString & rStr,const sal_Int32 nLen)86*1f882ec4SArmin Le Grand inline void lcl_skipDoubleAndSpacesAndCommas(sal_Int32& io_rPos, 87*1f882ec4SArmin Le Grand const ::rtl::OUString& rStr, 88*1f882ec4SArmin Le Grand const sal_Int32 nLen) 89*1f882ec4SArmin Le Grand { 90*1f882ec4SArmin Le Grand lcl_skipDouble(io_rPos, rStr); 91*1f882ec4SArmin Le Grand lcl_skipSpacesAndCommas(io_rPos, rStr, nLen); 92*1f882ec4SArmin Le Grand } 93*1f882ec4SArmin Le Grand lcl_putNumberChar(::rtl::OUStringBuffer & rStr,double fValue)94*1f882ec4SArmin Le Grand inline void lcl_putNumberChar( ::rtl::OUStringBuffer& rStr, 95*1f882ec4SArmin Le Grand double fValue ) 96*1f882ec4SArmin Le Grand { 97*1f882ec4SArmin Le Grand rStr.append( fValue ); 98*1f882ec4SArmin Le Grand } 99*1f882ec4SArmin Le Grand 100*1f882ec4SArmin Le Grand void lcl_putNumberCharWithSpace( ::rtl::OUStringBuffer& rStr, 101*1f882ec4SArmin Le Grand double fValue, 102*1f882ec4SArmin Le Grand double fOldValue, 103*1f882ec4SArmin Le Grand bool bUseRelativeCoordinates ); 104*1f882ec4SArmin Le Grand lcl_getCommand(sal_Char cUpperCaseCommand,sal_Char cLowerCaseCommand,bool bUseRelativeCoordinates)105*1f882ec4SArmin Le Grand inline sal_Unicode lcl_getCommand( sal_Char cUpperCaseCommand, 106*1f882ec4SArmin Le Grand sal_Char cLowerCaseCommand, 107*1f882ec4SArmin Le Grand bool bUseRelativeCoordinates ) 108*1f882ec4SArmin Le Grand { 109*1f882ec4SArmin Le Grand return bUseRelativeCoordinates ? cLowerCaseCommand : cUpperCaseCommand; 110*1f882ec4SArmin Le Grand } 111*1f882ec4SArmin Le Grand } // namespace internal 112*1f882ec4SArmin Le Grand } // namespace basegfx 113*1f882ec4SArmin Le Grand 114*1f882ec4SArmin Le Grand #endif /* _STRINGCONVERSIONTOOLS_HXX */ 115