configure.ac             |    1 
 src/lib/VSDXMLHelper.cpp |   50 +++++++++++------------------------------------
 2 files changed, 13 insertions(+), 38 deletions(-)

New commits:
commit c43a413414a8bd3cf4d61b5716606bfe8b4d060e
Author: Fridrich Å trba <fridrich.st...@bluewin.ch>
Date:   Mon Dec 16 13:35:48 2013 +0100

    Words cannot tell the love we have towards boost
    
    Change-Id: I0ab0b4858348a6b75de319672df808b6c73af87d

diff --git a/configure.ac b/configure.ac
index 7fa0150..9e4df06 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,6 +104,7 @@ AC_SUBST(ZLIB_LIBS)
 
 AC_CHECK_HEADERS(
        boost/algorithm/string.hpp \
+       boost/lexical_cast.hpp \
        boost/optional.hpp \
        boost/spirit/include/classic.hpp,
        [],
diff --git a/src/lib/VSDXMLHelper.cpp b/src/lib/VSDXMLHelper.cpp
index 2367a45..bef794d 100644
--- a/src/lib/VSDXMLHelper.cpp
+++ b/src/lib/VSDXMLHelper.cpp
@@ -34,6 +34,7 @@
 #include <istream>
 #include <vector>
 #include <boost/algorithm/string.hpp>
+#include <boost/lexical_cast.hpp>
 #include <libxml/xmlIO.h>
 #include <libxml/xmlstring.h>
 #include <librevenge-stream/librevenge-stream.h>
@@ -140,65 +141,38 @@ libvisio::Colour libvisio::xmlStringToColour(const 
xmlChar *s)
 
 long libvisio::xmlStringToLong(const xmlChar *s)
 {
+  using boost::lexical_cast;
+  using boost::bad_lexical_cast;
   if (xmlStrEqual(s, BAD_CAST("Themed")))
     return 0;
 
-  char *end;
-  errno = 0;
-  long value = strtol((const char *)s, &end, 0);
-
-  if ((ERANGE == errno && (LONG_MAX == value || LONG_MIN == value)) || (errno 
&& !value))
+  try
   {
-    VSD_DEBUG_MSG(("Throwing XmlParserException\n"));
-    throw XmlParserException();
+    return boost::lexical_cast<long, const char *>((const char *)s);
   }
-  else if (*end)
+  catch (const boost::bad_lexical_cast &)
   {
     VSD_DEBUG_MSG(("Throwing XmlParserException\n"));
     throw XmlParserException();
   }
-
-  return value;
+  return 0;
 }
 
 double libvisio::xmlStringToDouble(const xmlChar *s)
 {
   if (xmlStrEqual(s, BAD_CAST("Themed")))
-    return 0;
-
-  char *end;
-  std::string doubleStr((const char *)s);
-
-#ifndef __ANDROID__
-  std::string decimalPoint(localeconv()->decimal_point);
-#else
-  std::string decimalPoint(".");
-#endif
-  if (!decimalPoint.empty() && decimalPoint != ".")
-  {
-    if (!doubleStr.empty())
-    {
-      std::string::size_type pos;
-      while ((pos = doubleStr.find(".")) != std::string::npos)
-        doubleStr.replace(pos,1,decimalPoint);
-    }
-  }
+    return 0.0;
 
-  errno = 0;
-  double value = strtod(doubleStr.c_str(), &end);
-
-  if ((ERANGE == errno) || (errno && !value))
+  try
   {
-    VSD_DEBUG_MSG(("Throwing XmlParserException\n"));
-    throw XmlParserException();
+    return boost::lexical_cast<double, const char *>((const char *)s);
   }
-  else if (*end)
+  catch (const boost::bad_lexical_cast &)
   {
     VSD_DEBUG_MSG(("Throwing XmlParserException\n"));
     throw XmlParserException();
   }
-
-  return value;
+  return 0.0;
 }
 
 bool libvisio::xmlStringToBool(const xmlChar *s)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to