11f882ec4SArmin Le Grand /**************************************************************
21f882ec4SArmin Le Grand  *
31f882ec4SArmin Le Grand  * Licensed to the Apache Software Foundation (ASF) under one
41f882ec4SArmin Le Grand  * or more contributor license agreements.  See the NOTICE file
51f882ec4SArmin Le Grand  * distributed with this work for additional information
61f882ec4SArmin Le Grand  * regarding copyright ownership.  The ASF licenses this file
71f882ec4SArmin Le Grand  * to you under the Apache License, Version 2.0 (the
81f882ec4SArmin Le Grand  * "License"); you may not use this file except in compliance
91f882ec4SArmin Le Grand  * with the License.  You may obtain a copy of the License at
101f882ec4SArmin Le Grand  *
111f882ec4SArmin Le Grand  *   http://www.apache.org/licenses/LICENSE-2.0
121f882ec4SArmin Le Grand  *
131f882ec4SArmin Le Grand  * Unless required by applicable law or agreed to in writing,
141f882ec4SArmin Le Grand  * software distributed under the License is distributed on an
151f882ec4SArmin Le Grand  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
161f882ec4SArmin Le Grand  * KIND, either express or implied.  See the License for the
171f882ec4SArmin Le Grand  * specific language governing permissions and limitations
181f882ec4SArmin Le Grand  * under the License.
191f882ec4SArmin Le Grand  *
201f882ec4SArmin Le Grand  *************************************************************/
211f882ec4SArmin Le Grand 
221f882ec4SArmin Le Grand #ifndef _STRINGCONVERSIONTOOLS_HXX
231f882ec4SArmin Le Grand #define _STRINGCONVERSIONTOOLS_HXX
241f882ec4SArmin Le Grand 
251f882ec4SArmin Le Grand #include <sal/types.h>
261f882ec4SArmin Le Grand #include <rtl/ustring.hxx>
271f882ec4SArmin Le Grand #include <rtl/ustrbuf.hxx>
281f882ec4SArmin Le Grand 
291f882ec4SArmin Le Grand namespace basegfx
301f882ec4SArmin Le Grand {
311f882ec4SArmin Le Grand     namespace internal
321f882ec4SArmin Le Grand     {
331f882ec4SArmin Le Grand         void lcl_skipSpaces(sal_Int32& 				io_rPos,
341f882ec4SArmin Le Grand                             const ::rtl::OUString& 	rStr,
351f882ec4SArmin Le Grand                             const sal_Int32 		nLen);
361f882ec4SArmin Le Grand 
371f882ec4SArmin Le Grand         void lcl_skipSpacesAndCommas(sal_Int32& 			io_rPos,
381f882ec4SArmin Le Grand                                         const ::rtl::OUString& rStr,
391f882ec4SArmin Le Grand                                         const sal_Int32 		nLen);
401f882ec4SArmin Le Grand 
lcl_isOnNumberChar(const sal_Unicode aChar,bool bSignAllowed=true,bool bDotAllowed=true)41*788dccbdSArmin Le Grand         inline bool lcl_isOnNumberChar(const sal_Unicode aChar, bool bSignAllowed = true, bool bDotAllowed = true)
421f882ec4SArmin Le Grand         {
431f882ec4SArmin Le Grand             const bool bPredicate( (sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
441f882ec4SArmin Le Grand                                     || (bSignAllowed && sal_Unicode('+') == aChar)
45*788dccbdSArmin Le Grand                                     || (bSignAllowed && sal_Unicode('-') == aChar)
46*788dccbdSArmin Le Grand                                     || (bDotAllowed && sal_Unicode('.') == aChar));
471f882ec4SArmin Le Grand 
481f882ec4SArmin Le Grand             return bPredicate;
491f882ec4SArmin Le Grand         }
501f882ec4SArmin Le Grand 
lcl_isOnNumberChar(const::rtl::OUString & rStr,const sal_Int32 nPos,bool bSignAllowed=true,bool bDotAllowed=true)51*788dccbdSArmin Le Grand         inline bool lcl_isOnNumberChar(const ::rtl::OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true, bool bDotAllowed = true)
521f882ec4SArmin Le Grand         {
53*788dccbdSArmin Le Grand             return lcl_isOnNumberChar(rStr[nPos], bSignAllowed, bDotAllowed);
541f882ec4SArmin Le Grand         }
551f882ec4SArmin Le Grand 
561f882ec4SArmin Le Grand         bool lcl_getDoubleChar(double& 					o_fRetval,
571f882ec4SArmin Le Grand                                 sal_Int32& 				io_rPos,
581f882ec4SArmin Le Grand                                 const ::rtl::OUString& 	rStr);
591f882ec4SArmin Le Grand 
601f882ec4SArmin Le Grand         bool lcl_importDoubleAndSpaces( double& 				o_fRetval,
611f882ec4SArmin Le Grand                                         sal_Int32& 				io_rPos,
621f882ec4SArmin Le Grand                                         const ::rtl::OUString& 	rStr,
631f882ec4SArmin Le Grand                                         const sal_Int32 		nLen );
641f882ec4SArmin Le Grand 
651f882ec4SArmin Le Grand         bool lcl_importNumberAndSpaces(sal_Int32&                o_nRetval,
661f882ec4SArmin Le Grand                                         sal_Int32& 				io_rPos,
671f882ec4SArmin Le Grand                                         const ::rtl::OUString& 	rStr,
681f882ec4SArmin Le Grand                                         const sal_Int32 		nLen);
691f882ec4SArmin Le Grand 
701f882ec4SArmin Le Grand         void lcl_skipNumber(sal_Int32& 				io_rPos,
711f882ec4SArmin Le Grand                             const ::rtl::OUString& 	rStr,
721f882ec4SArmin Le Grand                             const sal_Int32 		nLen);
731f882ec4SArmin Le Grand 
741f882ec4SArmin Le Grand         void lcl_skipDouble(sal_Int32& 				io_rPos,
751f882ec4SArmin Le Grand                             const ::rtl::OUString& 	rStr);
761f882ec4SArmin Le Grand 
lcl_skipNumberAndSpacesAndCommas(sal_Int32 & io_rPos,const::rtl::OUString & rStr,const sal_Int32 nLen)771f882ec4SArmin Le Grand         inline void lcl_skipNumberAndSpacesAndCommas(sal_Int32& 				io_rPos,
781f882ec4SArmin Le Grand                                                 const ::rtl::OUString& 	rStr,
791f882ec4SArmin Le Grand                                                 const sal_Int32 			nLen)
801f882ec4SArmin Le Grand         {
811f882ec4SArmin Le Grand             lcl_skipNumber(io_rPos, rStr, nLen);
821f882ec4SArmin Le Grand             lcl_skipSpacesAndCommas(io_rPos, rStr, nLen);
831f882ec4SArmin Le Grand         }
841f882ec4SArmin Le Grand 
851f882ec4SArmin Le Grand         // #100617# Allow to skip doubles, too.
lcl_skipDoubleAndSpacesAndCommas(sal_Int32 & io_rPos,const::rtl::OUString & rStr,const sal_Int32 nLen)861f882ec4SArmin Le Grand         inline void lcl_skipDoubleAndSpacesAndCommas(sal_Int32& 				io_rPos,
871f882ec4SArmin Le Grand                                                 const ::rtl::OUString& 	rStr,
881f882ec4SArmin Le Grand                                                 const sal_Int32 			nLen)
891f882ec4SArmin Le Grand         {
901f882ec4SArmin Le Grand             lcl_skipDouble(io_rPos, rStr);
911f882ec4SArmin Le Grand             lcl_skipSpacesAndCommas(io_rPos, rStr, nLen);
921f882ec4SArmin Le Grand         }
931f882ec4SArmin Le Grand 
lcl_putNumberChar(::rtl::OUStringBuffer & rStr,double fValue)941f882ec4SArmin Le Grand         inline void lcl_putNumberChar( ::rtl::OUStringBuffer& rStr,
951f882ec4SArmin Le Grand                                 double 		 	       fValue )
961f882ec4SArmin Le Grand         {
971f882ec4SArmin Le Grand             rStr.append( fValue );
981f882ec4SArmin Le Grand         }
991f882ec4SArmin Le Grand 
1001f882ec4SArmin Le Grand         void lcl_putNumberCharWithSpace( ::rtl::OUStringBuffer& rStr,
1011f882ec4SArmin Le Grand                                             double 		        fValue,
1021f882ec4SArmin Le Grand                                             double 		        fOldValue,
1031f882ec4SArmin Le Grand                                             bool 			        bUseRelativeCoordinates );
1041f882ec4SArmin Le Grand 
lcl_getCommand(sal_Char cUpperCaseCommand,sal_Char cLowerCaseCommand,bool bUseRelativeCoordinates)1051f882ec4SArmin Le Grand         inline sal_Unicode lcl_getCommand( sal_Char cUpperCaseCommand,
1061f882ec4SArmin Le Grand                                             sal_Char cLowerCaseCommand,
1071f882ec4SArmin Le Grand                                             bool 	bUseRelativeCoordinates )
1081f882ec4SArmin Le Grand         {
1091f882ec4SArmin Le Grand             return bUseRelativeCoordinates ? cLowerCaseCommand : cUpperCaseCommand;
1101f882ec4SArmin Le Grand         }
1111f882ec4SArmin Le Grand     } // namespace internal
1121f882ec4SArmin Le Grand } // namespace basegfx
1131f882ec4SArmin Le Grand 
1141f882ec4SArmin Le Grand #endif /* _STRINGCONVERSIONTOOLS_HXX */
115