compilerplugins/clang/test/unnecessarygetstr.cxx     |   10 ++
 compilerplugins/clang/unnecessarygetstr.cxx          |   71 ++++++++++++-------
 connectivity/source/commontools/dbconversion.cxx     |    6 -
 desktop/qa/desktop_lib/test_desktop_lib.cxx          |    6 -
 desktop/source/lib/init.cxx                          |   10 +-
 lingucomponent/source/languageguessing/guesslang.cxx |   16 ++--
 lotuswordpro/source/filter/xfilter/xfutil.cxx        |    4 -
 sc/qa/unit/tiledrendering/tiledrendering.cxx         |   12 +--
 sd/qa/unit/tiledrendering/tiledrendering.cxx         |    6 -
 tools/source/generic/color.cxx                       |    4 -
 vcl/source/control/field2.cxx                        |    4 -
 vcl/source/gdi/mtfxmldump.cxx                        |    8 +-
 12 files changed, 93 insertions(+), 64 deletions(-)

New commits:
commit dba55c304a330a355147a39e53ec4c7cf5c5c3f5
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Apr 24 11:01:43 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Apr 24 12:45:22 2023 +0200

    loplugin:unnecessarygetstr extend to createFromAscii
    
    idea from mike kaganski
    
    Change-Id: I0ecb9cad091d7a048d2ddae73165bf22748f3872
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150907
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/compilerplugins/clang/test/unnecessarygetstr.cxx 
b/compilerplugins/clang/test/unnecessarygetstr.cxx
index 12905ec5d233..68ed153649ad 100644
--- a/compilerplugins/clang/test/unnecessarygetstr.cxx
+++ b/compilerplugins/clang/test/unnecessarygetstr.cxx
@@ -85,4 +85,14 @@ void test3(Foo2& foo)
 }
 }
 
+namespace test4
+{
+void test()
+{
+    std::string s;
+    // expected-error@+1 {{unnecessary call to 'c_str' when passing to 
OUString::createFromAscii [loplugin:unnecessarygetstr]}}
+    OUString::createFromAscii(s.c_str());
+}
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/compilerplugins/clang/unnecessarygetstr.cxx 
b/compilerplugins/clang/unnecessarygetstr.cxx
index 66f2fa2851fe..3caf3776e5f7 100644
--- a/compilerplugins/clang/unnecessarygetstr.cxx
+++ b/compilerplugins/clang/unnecessarygetstr.cxx
@@ -14,6 +14,7 @@
 
 #include "check.hxx"
 #include "plugin.hxx"
+#include "config_clang.h"
 
 // Find matches of
 //
@@ -82,39 +83,57 @@ public:
                 auto const tc1 = 
loplugin::TypeCheck(cxxConstruct->getConstructor()->getParent());
                 if (!(tc1.ClassOrStruct("basic_string_view").StdNamespace()))
                     continue;
-                auto e = 
dyn_cast<CXXMemberCallExpr>(cxxConstruct->getArg(0)->IgnoreImplicit());
-                if (!e)
-                    continue;
-                auto const t = e->getObjectType();
-                auto const tc2 = loplugin::TypeCheck(t);
-                if (tc2.Class("OString").Namespace("rtl").GlobalNamespace()
-                    || tc2.Class("OUString").Namespace("rtl").GlobalNamespace()
-                    || 
tc2.Class("OStringBuffer").Namespace("rtl").GlobalNamespace()
-                    || 
tc2.Class("OUStringBuffer").Namespace("rtl").GlobalNamespace()
-                    || 
tc2.ClassOrStruct("StringNumber").Namespace("rtl").GlobalNamespace())
-                {
-                    if 
(loplugin::DeclCheck(e->getMethodDecl()).Function("getStr"))
-                        report(DiagnosticsEngine::Warning,
-                               "unnecessary call to 'getStr' when passing to 
string_view arg",
-                               e->getExprLoc())
-                            << e->getSourceRange();
-                }
-                else if (tc2.Class("basic_string").StdNamespace())
-                {
-                    if 
(loplugin::DeclCheck(e->getMethodDecl()).Function("c_str"))
-                        report(DiagnosticsEngine::Warning,
-                               "unnecessary call to 'c_str' when passing to 
string_view arg",
-                               e->getExprLoc())
-                            << e->getSourceRange();
-                }
+                checkForGetStr(cxxConstruct->getArg(0), "string_view arg");
             }
         }
+        if (loplugin::DeclCheck(func)
+                .Function("createFromAscii")
+                .Class("OUString")
+                .Namespace("rtl"))
+        {
+            checkForGetStr(callExpr->getArg(0), "OUString::createFromAscii");
+        }
         return true;
     }
 
-    bool preRun() override { return compiler.getLangOpts().CPlusPlus; }
+    bool preRun() override
+    {
+        if (!compiler.getLangOpts().CPlusPlus)
+            return false;
+        std::string fn(handler.getMainFileName());
+        loplugin::normalizeDotDotInFilePath(fn);
+        if (loplugin::hasPathnamePrefix(fn, SRCDIR "/sal/qa/"))
+            return false;
+        return true;
+    }
 
 private:
+    void checkForGetStr(Expr* arg, const char* msg)
+    {
+        auto e = dyn_cast<CXXMemberCallExpr>(arg->IgnoreImplicit());
+        if (!e)
+            return;
+        auto const t = e->getObjectType();
+        auto const tc2 = loplugin::TypeCheck(t);
+        if (tc2.Class("OString").Namespace("rtl").GlobalNamespace()
+            || tc2.Class("OUString").Namespace("rtl").GlobalNamespace()
+            || tc2.Class("OStringBuffer").Namespace("rtl").GlobalNamespace()
+            || tc2.Class("OUStringBuffer").Namespace("rtl").GlobalNamespace()
+            || 
tc2.ClassOrStruct("StringNumber").Namespace("rtl").GlobalNamespace())
+        {
+            if (loplugin::DeclCheck(e->getMethodDecl()).Function("getStr"))
+                report(DiagnosticsEngine::Warning,
+                       "unnecessary call to 'getStr' when passing to %0", 
e->getExprLoc())
+                    << msg << e->getSourceRange();
+        }
+        else if (tc2.Class("basic_string").StdNamespace())
+        {
+            if (loplugin::DeclCheck(e->getMethodDecl()).Function("c_str"))
+                report(DiagnosticsEngine::Warning, "unnecessary call to 
'c_str' when passing to %0",
+                       e->getExprLoc())
+                    << msg << e->getSourceRange();
+        }
+    }
     void run() override
     {
         if (preRun())
diff --git a/connectivity/source/commontools/dbconversion.cxx 
b/connectivity/source/commontools/dbconversion.cxx
index fed51204afb7..704e168ad736 100644
--- a/connectivity/source/commontools/dbconversion.cxx
+++ b/connectivity/source/commontools/dbconversion.cxx
@@ -81,7 +81,7 @@ namespace dbtools
         ostr << setw(4) << rDate.Year  << "-"
              << setw(2) << rDate.Month << "-"
              << setw(2) << rDate.Day;
-        return OUString::createFromAscii(ostr.str().c_str());
+        return OUString::createFromAscii(ostr.str());
     }
 
     OUString DBTypeConversion::toTimeStringS(const css::util::Time& rTime)
@@ -92,7 +92,7 @@ namespace dbtools
         ostr << setw(2) << rTime.Hours   << ":"
              << setw(2) << rTime.Minutes << ":"
              << setw(2) << rTime.Seconds;
-        return OUString::createFromAscii(ostr.str().c_str());
+        return OUString::createFromAscii(ostr.str());
     }
 
     OUString DBTypeConversion::toTimeString(const css::util::Time& rTime)
@@ -104,7 +104,7 @@ namespace dbtools
              << setw(2) << rTime.Minutes << ":"
              << setw(2) << rTime.Seconds << "."
              << setw(9) << rTime.NanoSeconds;
-        return OUString::createFromAscii(ostr.str().c_str());
+        return OUString::createFromAscii(ostr.str());
     }
 
     OUString DBTypeConversion::toDateTimeString(const css::util::DateTime& 
_rDateTime)
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 59c883cb733d..dfc6d59e125e 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2347,7 +2347,7 @@ void DesktopLOKTest::testCommentsWriter()
         CPPUNIT_ASSERT(!rComment.second.get<std::string>("text").empty());
         // Has a valid iso 8601 date time string
         css::util::DateTime aDateTime;
-        OUString aDateTimeString = 
OUString::createFromAscii(rComment.second.get<std::string>("dateTime").c_str());
+        OUString aDateTimeString = 
OUString::createFromAscii(rComment.second.get<std::string>("dateTime"));
         CPPUNIT_ASSERT(utl::ISO8601parseDateTime(aDateTimeString, aDateTime));
 
         // This comment has a marked text range
@@ -2447,7 +2447,7 @@ void DesktopLOKTest::testCommentsImpress()
                 CPPUNIT_ASSERT_EQUAL(std::string("This is comment1"), 
rComment.second.get<std::string>("text"));
                 CPPUNIT_ASSERT_EQUAL(std::string("LOK User1"), 
rComment.second.get<std::string>("author"));
                 css::util::DateTime aDateTime;
-                OUString aDateTimeString = 
OUString::createFromAscii(rComment.second.get<std::string>("dateTime").c_str());
+                OUString aDateTimeString = 
OUString::createFromAscii(rComment.second.get<std::string>("dateTime"));
                 CPPUNIT_ASSERT(utl::ISO8601parseDateTime(aDateTimeString, 
aDateTime));
             }
             break;
@@ -2457,7 +2457,7 @@ void DesktopLOKTest::testCommentsImpress()
                 CPPUNIT_ASSERT_EQUAL(std::string("This is comment2"), 
rComment.second.get<std::string>("text"));
                 CPPUNIT_ASSERT_EQUAL(std::string("LOK User2"), 
rComment.second.get<std::string>("author"));
                 css::util::DateTime aDateTime;
-                OUString aDateTimeString = 
OUString::createFromAscii(rComment.second.get<std::string>("dateTime").c_str());
+                OUString aDateTimeString = 
OUString::createFromAscii(rComment.second.get<std::string>("dateTime"));
                 CPPUNIT_ASSERT(utl::ISO8601parseDateTime(aDateTimeString, 
aDateTime));
             }
             break;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a4f34cc349e8..742539da15e3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3041,7 +3041,7 @@ static bool lo_signDocument(LibreOfficeKit* /*pThis*/,
     std::string aCertificateBase64String = 
extractCertificate(aCertificateString);
     if (!aCertificateBase64String.empty())
     {
-        OUString aBase64OUString = 
OUString::createFromAscii(aCertificateBase64String.c_str());
+        OUString aBase64OUString = 
OUString::createFromAscii(aCertificateBase64String);
         comphelper::Base64::decode(aCertificateSequence, aBase64OUString);
     }
     else
@@ -3055,7 +3055,7 @@ static bool lo_signDocument(LibreOfficeKit* /*pThis*/,
     std::string aPrivateKeyBase64String = extractPrivateKey(aPrivateKeyString);
     if (!aPrivateKeyBase64String.empty())
     {
-        OUString aBase64OUString = 
OUString::createFromAscii(aPrivateKeyBase64String.c_str());
+        OUString aBase64OUString = 
OUString::createFromAscii(aPrivateKeyBase64String);
         comphelper::Base64::decode(aPrivateKeySequence, aBase64OUString);
     }
     else
@@ -6718,7 +6718,7 @@ static bool doc_insertCertificate(LibreOfficeKitDocument* 
pThis,
     std::string aCertificateBase64String = 
extractCertificate(aCertificateString);
     if (!aCertificateBase64String.empty())
     {
-        OUString aBase64OUString = 
OUString::createFromAscii(aCertificateBase64String.c_str());
+        OUString aBase64OUString = 
OUString::createFromAscii(aCertificateBase64String);
         comphelper::Base64::decode(aCertificateSequence, aBase64OUString);
     }
     else
@@ -6732,7 +6732,7 @@ static bool doc_insertCertificate(LibreOfficeKitDocument* 
pThis,
     std::string aPrivateKeyBase64String = extractPrivateKey(aPrivateKeyString);
     if (!aPrivateKeyBase64String.empty())
     {
-        OUString aBase64OUString = 
OUString::createFromAscii(aPrivateKeyBase64String.c_str());
+        OUString aBase64OUString = 
OUString::createFromAscii(aPrivateKeyBase64String);
         comphelper::Base64::decode(aPrivateKeySequence, aBase64OUString);
     }
     else
@@ -6790,7 +6790,7 @@ static bool doc_addCertificate(LibreOfficeKitDocument* 
pThis,
     std::string aCertificateBase64String = 
extractCertificate(aCertificateString);
     if (!aCertificateBase64String.empty())
     {
-        OUString aBase64OUString = 
OUString::createFromAscii(aCertificateBase64String.c_str());
+        OUString aBase64OUString = 
OUString::createFromAscii(aCertificateBase64String);
         comphelper::Base64::decode(aCertificateSequence, aBase64OUString);
     }
     else
diff --git a/lingucomponent/source/languageguessing/guesslang.cxx 
b/lingucomponent/source/languageguessing/guesslang.cxx
index 76576337914a..e88cd997caa0 100644
--- a/lingucomponent/source/languageguessing/guesslang.cxx
+++ b/lingucomponent/source/languageguessing/guesslang.cxx
@@ -169,8 +169,8 @@ Locale SAL_CALL LangGuess_Impl::guessPrimaryLanguage(
     OString o( OUStringToOString( rText.subView(nStartPos, nLen), 
RTL_TEXTENCODING_UTF8 ) );
     Guess g = m_aGuesser.GuessPrimaryLanguage(o.getStr());
     lang::Locale aRes;
-    aRes.Language   = OUString::createFromAscii( g.GetLanguage().c_str() );
-    aRes.Country    = OUString::createFromAscii( g.GetCountry().c_str() );
+    aRes.Language   = OUString::createFromAscii( g.GetLanguage() );
+    aRes.Country    = OUString::createFromAscii( g.GetCountry() );
     return aRes;
 }
 
@@ -200,8 +200,8 @@ uno::Sequence< Locale > SAL_CALL 
LangGuess_Impl::getAvailableLanguages(  )
 
     for(size_t i = 0; i < gs.size() ; i++ ){
         css::lang::Locale current_aRes;
-        current_aRes.Language   = OUString::createFromAscii( 
gs[i].GetLanguage().c_str() );
-        current_aRes.Country    = OUString::createFromAscii( 
gs[i].GetCountry().c_str() );
+        current_aRes.Language   = OUString::createFromAscii( 
gs[i].GetLanguage() );
+        current_aRes.Country    = OUString::createFromAscii( 
gs[i].GetCountry() );
         pRes[i] = current_aRes;
     }
 
@@ -222,8 +222,8 @@ uno::Sequence< Locale > SAL_CALL 
LangGuess_Impl::getEnabledLanguages(  )
 
     for(size_t i = 0; i < gs.size() ; i++ ){
         css::lang::Locale current_aRes;
-        current_aRes.Language   = OUString::createFromAscii( 
gs[i].GetLanguage().c_str() );
-        current_aRes.Country    = OUString::createFromAscii( 
gs[i].GetCountry().c_str() );
+        current_aRes.Language   = OUString::createFromAscii( 
gs[i].GetLanguage() );
+        current_aRes.Country    = OUString::createFromAscii( 
gs[i].GetCountry() );
         pRes[i] = current_aRes;
     }
 
@@ -244,8 +244,8 @@ uno::Sequence< Locale > SAL_CALL 
LangGuess_Impl::getDisabledLanguages(  )
 
     for(size_t i = 0; i < gs.size() ; i++ ){
         css::lang::Locale current_aRes;
-        current_aRes.Language   = OUString::createFromAscii( 
gs[i].GetLanguage().c_str() );
-        current_aRes.Country    = OUString::createFromAscii( 
gs[i].GetCountry().c_str() );
+        current_aRes.Language   = OUString::createFromAscii( 
gs[i].GetLanguage() );
+        current_aRes.Country    = OUString::createFromAscii( 
gs[i].GetCountry() );
         pRes[i] = current_aRes;
     }
 
diff --git a/lotuswordpro/source/filter/xfilter/xfutil.cxx 
b/lotuswordpro/source/filter/xfilter/xfutil.cxx
index dd212b21a64d..b396f2f6f1d3 100644
--- a/lotuswordpro/source/filter/xfilter/xfutil.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfutil.cxx
@@ -69,7 +69,7 @@ OUString   GetTableColName(sal_Int32 col)
     {
         ch = 'A' + col -1;
         strOut += ch;
-        return OUString::createFromAscii(strOut.c_str());
+        return OUString::createFromAscii(strOut);
     }
 
     while( col>26 )
@@ -82,7 +82,7 @@ OUString   GetTableColName(sal_Int32 col)
 
     ch = 'A' + remain -1;
     strOut += ch;
-    return OUString::createFromAscii(strOut.c_str());
+    return OUString::createFromAscii(strOut);
 }
 
 //tool functions:
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 3e6accfe2c4b..6f9398f03736 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -317,13 +317,13 @@ struct EditCursorMessage final {
         else
             return; // happens in testTextBoxInsert test
 
-        uno::Sequence<OUString> aSeq = 
comphelper::string::convertCommaSeparated(OUString::createFromAscii(aVal.c_str()));
+        uno::Sequence<OUString> aSeq = 
comphelper::string::convertCommaSeparated(OUString::createFromAscii(aVal));
         CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aSeq.getLength());
         m_aRefPoint.setX(aSeq[0].toInt32());
         m_aRefPoint.setY(aSeq[1].toInt32());
 
         aVal = aTree.get_child("relrect").get_value<std::string>();
-        aSeq = 
comphelper::string::convertCommaSeparated(OUString::createFromAscii(aVal.c_str()));
+        aSeq = 
comphelper::string::convertCommaSeparated(OUString::createFromAscii(aVal));
         CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aSeq.getLength());
         m_aRelRect.SetLeft(aSeq[0].toInt32());
         m_aRelRect.SetTop(aSeq[1].toInt32());
@@ -369,7 +369,7 @@ struct TextSelectionMessage
         std::string aRefPointString = (nRefDelimStart == std::string::npos) ?
             std::string("0, 0") :
             aStr.substr(nRefDelimStart + 2, aStr.length() - 2 - 
nRefDelimStart);
-        uno::Sequence<OUString> aSeq = 
comphelper::string::convertCommaSeparated(OUString::createFromAscii(aRefPointString.c_str()));
+        uno::Sequence<OUString> aSeq = 
comphelper::string::convertCommaSeparated(OUString::createFromAscii(aRefPointString));
         CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aSeq.getLength());
         m_aRefPoint.setX(aSeq[0].toInt32());
         m_aRefPoint.setY(aSeq[1].toInt32());
@@ -382,7 +382,7 @@ struct TextSelectionMessage
         {
             std::string aRectString = aRectListString.substr(nStart, nEnd - 
nStart);
             {
-                aSeq = 
comphelper::string::convertCommaSeparated(OUString::createFromAscii(aRectString.c_str()));
+                aSeq = 
comphelper::string::convertCommaSeparated(OUString::createFromAscii(aRectString));
                 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aSeq.getLength());
                 tools::Rectangle aRect;
                 aRect.SetLeft(aSeq[0].toInt32());
@@ -1123,7 +1123,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testCommentCallback)
             pTabViewShell->SetCursor(3, 100);
         aArgs = comphelper::InitPropertySequence(
         {
-            {"Id", uno::Any(OUString::createFromAscii(aCommentId.c_str()))},
+            {"Id", uno::Any(OUString::createFromAscii(aCommentId))},
             {"Text", uno::Any(OUString("Edited comment"))},
             {"Author", uno::Any(OUString("LOK User2"))},
         });
@@ -1146,7 +1146,7 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testCommentCallback)
             pTabViewShell->SetCursor(4, 43);
         aArgs = comphelper::InitPropertySequence(
         {
-            {"Id", uno::Any(OUString::createFromAscii(aCommentId.c_str()))}
+            {"Id", uno::Any(OUString::createFromAscii(aCommentId))}
         });
         dispatchCommand(mxComponent, ".uno:DeleteNote", aArgs);
 
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 12d7159e9faa..ece4c3ad32e6 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1688,7 +1688,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, 
testCommentCallbacks)
     int nComment1 = aView1.m_aCommentCallbackResult.get<int>("id");
     CPPUNIT_ASSERT_EQUAL(nComment1, 
aView2.m_aCommentCallbackResult.get<int>("id"));
     css::util::DateTime aDateTime;
-    OUString aDateTimeString = 
OUString::createFromAscii(aView1.m_aCommentCallbackResult.get<std::string>("dateTime").c_str());
+    OUString aDateTimeString = 
OUString::createFromAscii(aView1.m_aCommentCallbackResult.get<std::string>("dateTime"));
     CPPUNIT_ASSERT(utl::ISO8601parseDateTime(aDateTimeString, aDateTime));
     CPPUNIT_ASSERT_EQUAL(std::string("LOK User1"), 
aView1.m_aCommentCallbackResult.get<std::string>("author"));
     CPPUNIT_ASSERT_EQUAL(std::string("LOK User1"), 
aView2.m_aCommentCallbackResult.get<std::string>("author"));
@@ -1713,8 +1713,8 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, 
testCommentCallbacks)
     CPPUNIT_ASSERT_EQUAL(nComment1, 
aView2.m_aCommentCallbackResult.get<int>("id"));
     CPPUNIT_ASSERT_EQUAL(std::string("LOK User2"), 
aView1.m_aCommentCallbackResult.get<std::string>("author"));
     CPPUNIT_ASSERT_EQUAL(std::string("LOK User2"), 
aView2.m_aCommentCallbackResult.get<std::string>("author"));
-    OUString aReplyTextView1 = 
OUString::createFromAscii(aView1.m_aCommentCallbackResult.get<std::string>("text").c_str());
-    OUString aReplyTextView2 = 
OUString::createFromAscii(aView2.m_aCommentCallbackResult.get<std::string>("text").c_str());
+    OUString aReplyTextView1 = 
OUString::createFromAscii(aView1.m_aCommentCallbackResult.get<std::string>("text"));
+    OUString aReplyTextView2 = 
OUString::createFromAscii(aView2.m_aCommentCallbackResult.get<std::string>("text"));
     CPPUNIT_ASSERT(aReplyTextView1.startsWith("Reply to LOK User1"));
     CPPUNIT_ASSERT(aReplyTextView1.endsWith("Reply to comment"));
     CPPUNIT_ASSERT(aReplyTextView2.startsWith("Reply to LOK User1"));
diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx
index 1c740f03df03..421045b588a9 100644
--- a/tools/source/generic/color.cxx
+++ b/tools/source/generic/color.cxx
@@ -195,14 +195,14 @@ OUString Color::AsRGBHexString() const
 {
     std::stringstream ss;
     ss << std::hex << std::setfill ('0') << std::setw(6) << 
sal_uInt32(GetRGBColor());
-    return OUString::createFromAscii(ss.str().c_str());
+    return OUString::createFromAscii(ss.str());
 }
 
 OUString Color::AsRGBHEXString() const
 {
     std::stringstream ss;
     ss << std::hex << std::uppercase << std::setfill ('0') << std::setw(6) << 
sal_uInt32(GetRGBColor());
-    return OUString::createFromAscii(ss.str().c_str());
+    return OUString::createFromAscii(ss.str());
 }
 
 void Color::ApplyTintOrShade(sal_Int16 n100thPercent)
diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx
index be02536ef513..726af088d89c 100644
--- a/vcl/source/control/field2.cxx
+++ b/vcl/source/control/field2.cxx
@@ -2553,7 +2553,7 @@ void TimeFormatter::ImplTimeReformat( std::u16string_view 
rStr, OUString& rOutSt
         ostr.fill('0');
         ostr.width(9);
         ostr << aTempTime.GetNanoSec();
-        rOutStr += OUString::createFromAscii(ostr.str().c_str());
+        rOutStr += OUString::createFromAscii(ostr.str());
     }
     else if ( mbDuration )
         rOutStr = ImplGetLocaleDataWrapper().getDuration( aTempTime, bSecond, 
b100Sec );
@@ -2784,7 +2784,7 @@ OUString TimeFormatter::FormatTime(const tools::Time& 
rNewTime, TimeFieldFormat
         ostr.fill('0');
         ostr.width(9);
         ostr << rNewTime.GetNanoSec();
-        aStr += OUString::createFromAscii(ostr.str().c_str());
+        aStr += OUString::createFromAscii(ostr.str());
     }
     else if ( bDuration )
     {
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 7092ebfa54fc..fc38ee0a5a97 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -371,7 +371,7 @@ OUString convertFractionToString(const Fraction& aFraction)
 
     ss << aFraction;
 
-    return OUString::createFromAscii(ss.str().c_str());
+    return OUString::createFromAscii(ss.str());
 }
 
 OUString convertGradientStyleToOUString(css::awt::GradientStyle eStyle)
@@ -405,7 +405,7 @@ OUString convertLanguageTypeToString(LanguageType 
rLanguageType)
 {
     std::stringstream ss;
     ss << std::hex << std::setfill ('0') << std::setw(4) << 
rLanguageType.get();
-    return "#" + OUString::createFromAscii(ss.str().c_str());
+    return "#" + OUString::createFromAscii(ss.str());
 }
 
 OUString convertWallpaperStyleToString(WallpaperStyle eWallpaperStyle)
@@ -480,7 +480,7 @@ OUString hex32(sal_uInt32 nNumber)
 {
     std::stringstream ss;
     ss << std::hex << std::setfill('0') << std::setw(8) << nNumber;
-    return OUString::createFromAscii(ss.str().c_str());
+    return OUString::createFromAscii(ss.str());
 }
 
 OUString toHexString(const sal_uInt8* nData, sal_uInt32 nDataSize){
@@ -491,7 +491,7 @@ OUString toHexString(const sal_uInt8* nData, sal_uInt32 
nDataSize){
         aStrm << std::setw(2) << std::setfill('0') << std::hex << 
static_cast<int>(nData[i]);
     }
 
-    return OUString::createFromAscii(aStrm.str().c_str());
+    return OUString::createFromAscii(aStrm.str());
 }
 
 void writePoint(tools::XmlWriter& rWriter, Point const& rPoint)

Reply via email to