From fc0d57b7aff84f4bdca0a1f201527c265d5f0cf5 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 6 Nov 2014 17:24:13 +0100 Subject: Revert "use the new OUString::fromUtf8 method" This reverts commit 05050cdb23de586870bf479a9df5ced06828d498, not all places that use e.g. OStringToOUString to convert potential UTF-8 are guaranteed to fulfil the prerequisites necessary to use fromUtf8 (and some places like e.g. in codemaker are happy with the best-effort effect of OStringToOUString's OSTRING_TO_OUSTRING_CVTFLAGS). --- unoxml/source/dom/attr.cxx | 6 ++++-- unoxml/source/dom/characterdata.cxx | 8 ++++---- unoxml/source/rdf/librdf_repository.cxx | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 10 deletions(-) (limited to 'unoxml/source') diff --git a/unoxml/source/dom/attr.cxx b/unoxml/source/dom/attr.cxx index f835e6dab6de..68c5c82a4e6b 100644 --- a/unoxml/source/dom/attr.cxx +++ b/unoxml/source/dom/attr.cxx @@ -238,7 +238,8 @@ namespace DOM if (m_pNamespace.get()) { OSL_ASSERT(!m_aNodePtr->parent); - OUString const ret(OUString::fromUtf8(m_pNamespace->second)); + OUString const ret(OStringToOUString( + m_pNamespace->second, RTL_TEXTENCODING_UTF8)); return ret; } else { return CNode::getPrefix(); @@ -254,7 +255,8 @@ namespace DOM if (m_pNamespace.get()) { OSL_ASSERT(!m_aNodePtr->parent); - OUString const ret(OUString::fromUtf8(m_pNamespace->first)); + OUString const ret(OStringToOUString( + m_pNamespace->first, RTL_TEXTENCODING_UTF8)); return ret; } else { return CNode::getNamespaceURI(); diff --git a/unoxml/source/dom/characterdata.cxx b/unoxml/source/dom/characterdata.cxx index 9f5888dba942..1033a7c9aabf 100644 --- a/unoxml/source/dom/characterdata.cxx +++ b/unoxml/source/dom/characterdata.cxx @@ -88,7 +88,7 @@ namespace DOM ::boost::shared_ptr const pContent( xmlNodeGetContent(m_aNodePtr), xmlFree); OString aData(reinterpret_cast(pContent.get())); - OUString tmp(OUString::fromUtf8(aData)); + OUString tmp(OStringToOUString(aData, RTL_TEXTENCODING_UTF8)); if (offset > tmp.getLength() || offset < 0 || count < 0) { DOMException e; e.Code = DOMExceptionType_INDEX_SIZE_ERR; @@ -159,7 +159,7 @@ namespace DOM ::boost::shared_ptr const pContent( xmlNodeGetContent(m_aNodePtr), xmlFree); OString aData(reinterpret_cast(pContent.get())); - OUString tmp(OUString::fromUtf8(aData)); + OUString tmp(OStringToOUString(aData, RTL_TEXTENCODING_UTF8)); if (offset > tmp.getLength() || offset < 0) { DOMException e; e.Code = DOMExceptionType_INDEX_SIZE_ERR; @@ -194,7 +194,7 @@ namespace DOM ::boost::shared_ptr const pContent( xmlNodeGetContent(m_aNodePtr), xmlFree); OString aData(reinterpret_cast(pContent.get())); - OUString tmp(OUString::fromUtf8(aData)); + OUString tmp(OStringToOUString(aData, RTL_TEXTENCODING_UTF8)); if (offset > tmp.getLength() || offset < 0 || count < 0){ DOMException e; e.Code = DOMExceptionType_INDEX_SIZE_ERR; @@ -249,7 +249,7 @@ namespace DOM ::boost::shared_ptr const pContent( xmlNodeGetContent(m_aNodePtr), xmlFree); OString aData(reinterpret_cast(pContent.get())); - OUString tmp(OUString::fromUtf8(aData)); + OUString tmp(OStringToOUString(aData, RTL_TEXTENCODING_UTF8)); if (offset > tmp.getLength() || offset < 0 || count < 0) { DOMException e; e.Code = DOMExceptionType_INDEX_SIZE_ERR; diff --git a/unoxml/source/rdf/librdf_repository.cxx b/unoxml/source/rdf/librdf_repository.cxx index 0013f400b98d..1bec82992295 100644 --- a/unoxml/source/rdf/librdf_repository.cxx +++ b/unoxml/source/rdf/librdf_repository.cxx @@ -2319,7 +2319,9 @@ librdf_TypeConverter::convertToXURI(librdf_uri* i_pURI) const "librdf_TypeConverter::convertToXURI: " "librdf_uri_as_string failed", m_rRep); } - OUString uriU( OUString::fromUtf8( OString(reinterpret_cast(uri))) ); + OUString uriU( OStringToOUString( + OString(reinterpret_cast(uri)), + RTL_TEXTENCODING_UTF8) ); try { return rdf::URI::create(m_xContext, uriU); } catch (const lang::IllegalArgumentException & iae) { @@ -2358,7 +2360,9 @@ librdf_TypeConverter::convertToXResource(librdf_node* i_pNode) const "librdf_TypeConverter::convertToXResource: " "blank node has no label", m_rRep); } - OUString labelU( OUString::fromUtf8( OString(reinterpret_cast(label))) ); + OUString labelU( OStringToOUString( + OString(reinterpret_cast(label)), + RTL_TEXTENCODING_UTF8) ); try { return uno::Reference( rdf::BlankNode::create(m_xContext, labelU), uno::UNO_QUERY); @@ -2391,9 +2395,13 @@ librdf_TypeConverter::convertToXNode(librdf_node* i_pNode) const librdf_uri* pType( librdf_node_get_literal_value_datatype_uri(i_pNode) ); OSL_ENSURE(!lang || !pType, "convertToXNode: invalid literal"); - const OUString valueU( OUString::fromUtf8(OString(reinterpret_cast(value))) ); + const OUString valueU( OStringToOUString( + OString(reinterpret_cast(value)), + RTL_TEXTENCODING_UTF8) ); if (lang) { - const OUString langU( OUString::fromUtf8( OString(reinterpret_cast(lang))) ); + const OUString langU( OStringToOUString( + OString(reinterpret_cast(lang)), + RTL_TEXTENCODING_UTF8) ); return uno::Reference( rdf::Literal::createWithLanguage(m_xContext, valueU, langU), uno::UNO_QUERY); -- cgit v1.2.3