From 93c64a61f2c84e684050294a1391cd32425b7837 Mon Sep 17 00:00:00 2001 From: Noel Date: Fri, 6 Nov 2020 20:01:50 +0200 Subject: loplugin:stringview Add new methods "subView" to O(U)String to return substring views of the underlying data. Add a clang plugin to warn when replacing existing calls to copy() would be better to use subView(). Change-Id: I03a5732431ce60808946f2ce2c923b22845689ca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105420 Tested-by: Jenkins Reviewed-by: Noel Grandin --- unoxml/source/dom/characterdata.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'unoxml') diff --git a/unoxml/source/dom/characterdata.cxx b/unoxml/source/dom/characterdata.cxx index ee85a76b4a68..d46ff5d7c587 100644 --- a/unoxml/source/dom/characterdata.cxx +++ b/unoxml/source/dom/characterdata.cxx @@ -98,7 +98,7 @@ namespace DOM if ((offset+count) > tmp.getLength()) count = tmp.getLength() - offset; - OUString tmp2 = tmp.copy(0, offset) + tmp.copy(offset+count); + OUString tmp2 = OUString::Concat(tmp.subView(0, offset)) + tmp.subView(offset+count); OUString oldValue(reinterpret_cast(m_aNodePtr->content), strlen(reinterpret_cast(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8); xmlNodeSetContent(m_aNodePtr, reinterpret_cast(OUStringToOString(tmp2, RTL_TEXTENCODING_UTF8).getStr())); OUString newValue(reinterpret_cast(m_aNodePtr->content), strlen(reinterpret_cast(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8); @@ -166,9 +166,9 @@ namespace DOM throw e; } - OUString tmp2 = tmp.copy(0, offset) + + OUString tmp2 = tmp.subView(0, offset) + arg + - tmp.copy(offset); + tmp.subView(offset); OUString oldValue(reinterpret_cast(m_aNodePtr->content), strlen(reinterpret_cast(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8); xmlNodeSetContent(m_aNodePtr, reinterpret_cast(OUStringToOString(tmp2, RTL_TEXTENCODING_UTF8).getStr())); OUString newValue(reinterpret_cast(m_aNodePtr->content), strlen(reinterpret_cast(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8); @@ -203,9 +203,9 @@ namespace DOM if ((offset+count) > tmp.getLength()) count = tmp.getLength() - offset; - OUString tmp2 = tmp.copy(0, offset) + + OUString tmp2 = tmp.subView(0, offset) + arg + - tmp.copy(offset+count); + tmp.subView(offset+count); OUString oldValue(reinterpret_cast(m_aNodePtr->content), strlen(reinterpret_cast(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8); xmlNodeSetContent(m_aNodePtr, reinterpret_cast(OUStringToOString(tmp2, RTL_TEXTENCODING_UTF8).getStr())); OUString newValue(reinterpret_cast(m_aNodePtr->content), strlen(reinterpret_cast(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8); -- cgit