[Libreoffice-commits] core.git: filter/source

Xisco Fauli anistenis at gmail.com
Mon Nov 16 23:57:49 PST 2015


 filter/source/svg/parserfragments.cxx |   21 +++++++++------------
 filter/source/svg/parserfragments.hxx |    4 ++--
 filter/source/svg/svgreader.cxx       |    9 ++++-----
 3 files changed, 15 insertions(+), 19 deletions(-)

New commits:
commit 970813b0a4ac0bd1e07dfb0803bdebca9c3e9e6a
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Mon Nov 16 23:21:59 2015 +0100

    instead of converting from std::string to OUString...
    
    ... use OUString directly
    
    Change-Id: Ibdf863d7dbbb578e7fe87eac51e3d773a5b05199
    Reviewed-on: https://gerrit.libreoffice.org/20009
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/filter/source/svg/parserfragments.cxx b/filter/source/svg/parserfragments.cxx
index ec01fdf..4e4e537 100644
--- a/filter/source/svg/parserfragments.cxx
+++ b/filter/source/svg/parserfragments.cxx
@@ -15,7 +15,6 @@
 #include <com/sun/star/geometry/AffineMatrix2D.hpp>
 #include <osl/diagnose.h>
 
-#include <string.h>
 #include <limits.h>
 #include <boost/bind.hpp>
 #include <boost/spirit/include/classic.hpp>
@@ -573,22 +572,20 @@ bool parsePaintUri( std::pair<const char*,const char*>& o_rPaintUri,
 
 
 
-bool parseXlinkHref( const char* sXlinkHref, std::string& data )
+bool parseXlinkHref( const char* sXlinkHref, OUString& data )
 {
-    using namespace ::boost::spirit::classic;
-
-    data.erase(data.begin(),data.end());
+    OUString sLink(OUString::createFromAscii(sXlinkHref));
 
-    std::string sLink(sXlinkHref);
-
-    if (!sLink.compare(0,5,"data:"))
+    if (sLink.startsWith("data:"))
     {
+        sal_Int32 nIndex=0;
+        OUString aCurrToken = sLink.getToken(0,',',nIndex);
+
         // the inplace "data" uri
-        size_t position = sLink.rfind(',');
-        if (position > 0 && position < std::string::npos)
+        if ( !aCurrToken.isEmpty() )
         {
-            data = sLink.substr(position+1);
-            OSL_TRACE("%s", data.c_str());
+            data = sLink.copy(nIndex);
+            SAL_INFO("%s", data);
             return true;
         }
     }
diff --git a/filter/source/svg/parserfragments.hxx b/filter/source/svg/parserfragments.hxx
index 6d4c352..a93a5fb 100644
--- a/filter/source/svg/parserfragments.hxx
+++ b/filter/source/svg/parserfragments.hxx
@@ -12,7 +12,7 @@
 #include <sal/config.h>
 #include <vector>
 #include <utility>
-#include <string>
+#include <rtl/ustring.hxx>
 
 namespace basegfx
 {
@@ -60,7 +60,7 @@ namespace svgi
                         const char*                         sPaintUri );
 
     /// Parse given string for the xlink attribute
-    bool parseXlinkHref( const char* xlink, std::string& data );
+    bool parseXlinkHref( const char* xlink, OUString& data );
 
 } // namespace svgi
 
diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
index 4c0d3c8..0554099 100644
--- a/filter/source/svg/svgreader.cxx
+++ b/filter/source/svg/svgreader.cxx
@@ -44,7 +44,6 @@
 
 #include <boost/bind.hpp>
 #include <map>
-#include <string.h>
 
 #define OASIS_STR "urn:oasis:names:tc:opendocument:xmlns:"
 
@@ -1539,10 +1538,10 @@ struct ShapeWritingVisitor
 
                 OUString sValue = xElem->hasAttribute("href") ? xElem->getAttribute("href") : "";
                 OString aValueUtf8( sValue.getStr(), sValue.getLength(), RTL_TEXTENCODING_UTF8 );
-                std::string sLinkValue;
+                OUString sLinkValue;
                 parseXlinkHref(aValueUtf8.getStr(), sLinkValue);
 
-                if (!sLinkValue.empty())
+                if (!sLinkValue.isEmpty())
                     writeBinaryData(xAttrs, xUnoAttrs, xElem, basegfx::B2DRange(x,y,x+width,y+height), sLinkValue);
                 break;
             }
@@ -1642,7 +1641,7 @@ struct ShapeWritingVisitor
                         const uno::Reference<xml::sax::XAttributeList>& xUnoAttrs,
                         const uno::Reference<xml::dom::XElement>&       /* xElem */,
                         const basegfx::B2DRange&                        rShapeBounds,
-                        const std::string&                              data)
+                        const OUString&                                 data)
     {
         xAttrs->Clear();
         xAttrs->AddAttribute( "svg:x", OUString::number(pt2mm(rShapeBounds.getMinX()))+"mm");
@@ -1657,7 +1656,7 @@ struct ShapeWritingVisitor
 
         mxDocumentHandler->startElement("office:binary-data", xUnoAttrs);
 
-        mxDocumentHandler->characters(OUString::createFromAscii(data.c_str()));
+        mxDocumentHandler->characters(data);
 
         mxDocumentHandler->endElement("office:binary-data");
 


More information about the Libreoffice-commits mailing list