[Libreoffice-commits] core.git: compilerplugins/clang include/rtl starmath/qa svtools/source sw/qa vcl/qa

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Sat Aug 29 06:13:19 UTC 2020


 compilerplugins/clang/elidestringvar.cxx        |    5 +
 compilerplugins/clang/stringconstant.cxx        |    4 +
 include/rtl/ustring.hxx                         |   73 +++++++++++++++++++++---
 starmath/qa/cppunit/test_nodetotextvisitors.cxx |    6 -
 svtools/source/misc/sampletext.cxx              |    8 +-
 sw/qa/extras/rtfexport/rtfexport.cxx            |   20 ++----
 sw/qa/extras/rtfexport/rtfexport2.cxx           |   21 ++----
 sw/qa/extras/rtfexport/rtfexport5.cxx           |   23 ++-----
 sw/qa/extras/rtfimport/rtfimport.cxx            |    7 --
 sw/qa/extras/uiwriter/uiwriter.cxx              |   12 +--
 vcl/qa/cppunit/pdfexport/pdfexport.cxx          |    4 -
 11 files changed, 116 insertions(+), 67 deletions(-)

New commits:
commit a1570b6052ae9c9349282027c9007b071589bce6
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Aug 28 16:05:56 2020 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Sat Aug 29 08:12:33 2020 +0200

    Make the OUString ConstCharArrayDetector::TypeUtf16 overloads are actually used
    
    0c8fa58a2d73702770687ed15b98822d09f96ac3 "Support ConstCharArrayDetector also
    for UTF-16 arrays" had introduced those LIBO_INTERNAL_ONLY ctor and operator ==
    overloads, but they never got called because the existing 'sal_Unicode const *'
    overloads always won.
    
    (The other function overloads introduced with
    0c8fa58a2d73702770687ed15b98822d09f96ac3 should be unproblematic, as they do not
    have any 'sal_Unicode const *' overload counterparts.)
    
    Also fix the resulting loplugin:elidestringvar and loplugin:stringconstant
    fallout.  For one, those plugins look at the actual ctor overloads being used,
    so had missed those cases that accidentally had used an unexpected overload.
    And for another, the heuristic the plugins used to detect the
    ConstCharArrayDetector overloads turned out to be too simplistic now and would
    have started to cause false positives.
    
    Change-Id: I4426890979fb832d53f391c7e1b62bc1ad501a65
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101582
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/compilerplugins/clang/elidestringvar.cxx b/compilerplugins/clang/elidestringvar.cxx
index d091f8175783..561e14c17a40 100644
--- a/compilerplugins/clang/elidestringvar.cxx
+++ b/compilerplugins/clang/elidestringvar.cxx
@@ -139,6 +139,11 @@ public:
             }
             case 2:
             {
+                auto const t = e1->getArg(0)->getType();
+                if (!(t.isConstQualified() && t->isConstantArrayType()))
+                {
+                    return true;
+                }
                 auto const e2 = e1->getArg(1);
                 if (!(isa<CXXDefaultArgExpr>(e2)
                       && loplugin::TypeCheck(e2->getType())
diff --git a/compilerplugins/clang/stringconstant.cxx b/compilerplugins/clang/stringconstant.cxx
index cafcd0763a14..372dbceb92ba 100644
--- a/compilerplugins/clang/stringconstant.cxx
+++ b/compilerplugins/clang/stringconstant.cxx
@@ -1297,6 +1297,10 @@ bool StringConstant::VisitReturnStmt(ReturnStmt const * stmt) {
     if (e4->getNumArgs() != 2) {
         return true;
     }
+    auto const t = e4->getArg(0)->getType();
+    if (!(t.isConstQualified() && t->isConstantArrayType())) {
+        return true;
+    }
     auto const e5 = e4->getArg(1);
     if (!(isa<CXXDefaultArgExpr>(e5)
           && (loplugin::TypeCheck(e5->getType()).Struct("Dummy").Namespace("libreoffice_internal")
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 2f9518029be1..229ed22aeb45 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -211,6 +211,25 @@ public:
     /// @endcond
 #endif
 
+#if defined LIBO_INTERNAL_ONLY
+
+    template<typename T> OUString(
+        T const & value,
+        typename libreoffice_internal::CharPtrDetector<T, libreoffice_internal::Dummy>::TypeUtf16
+            = libreoffice_internal::Dummy()):
+        pData(nullptr)
+    { rtl_uString_newFromStr(&pData, value); }
+
+    template<typename T> OUString(
+        T & value,
+        typename
+        libreoffice_internal::NonConstCharArrayDetector<T, libreoffice_internal::Dummy>::TypeUtf16
+            = libreoffice_internal::Dummy()):
+        pData(nullptr)
+    { rtl_uString_newFromStr(&pData, value); }
+
+#else
+
     /**
       New string from a Unicode character buffer array.
 
@@ -222,6 +241,8 @@ public:
         rtl_uString_newFromStr( &pData, value );
     }
 
+#endif
+
     /**
       New string from a Unicode character buffer array.
 
@@ -1744,17 +1765,9 @@ public:
 
     friend bool     operator == ( const OUString& rStr1,    const OUString& rStr2 )
                         { return rStr1.equals(rStr2); }
-    friend bool     operator == ( const OUString& rStr1,    const sal_Unicode * pStr2 )
-                        { return rStr1.compareTo( pStr2 ) == 0; }
-    friend bool     operator == ( const sal_Unicode * pStr1,    const OUString& rStr2 )
-                        { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
 
     friend bool     operator != ( const OUString& rStr1,        const OUString& rStr2 )
                         { return !(operator == ( rStr1, rStr2 )); }
-    friend bool     operator != ( const OUString& rStr1,    const sal_Unicode * pStr2 )
-                        { return !(operator == ( rStr1, pStr2 )); }
-    friend bool     operator != ( const sal_Unicode * pStr1,    const OUString& rStr2 )
-                        { return !(operator == ( pStr1, rStr2 )); }
 
     friend bool     operator <  ( const OUString& rStr1,    const OUString& rStr2 )
                         { return rStr1.compareTo( rStr2 ) < 0; }
@@ -1765,6 +1778,50 @@ public:
     friend bool     operator >= ( const OUString& rStr1,    const OUString& rStr2 )
                         { return rStr1.compareTo( rStr2 ) >= 0; }
 
+#if defined LIBO_INTERNAL_ONLY
+
+    template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
+    operator ==(OUString const & s1, T const & s2) { return s1.compareTo(s2) == 0; }
+
+    template<typename T>
+    friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
+    operator ==(OUString const & s1, T & s2) { return s1.compareTo(s2) == 0; }
+
+    template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
+    operator ==(T const & s1, OUString const & s2) { return s2.compareTo(s1) == 0; }
+
+    template<typename T>
+    friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
+    operator ==(T & s1, OUString const & s2) { return s2.compareTo(s1) == 0; }
+
+    template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
+    operator !=(OUString const & s1, T const & s2) { return !(s1 == s2); }
+
+    template<typename T>
+    friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
+    operator !=(OUString const & s1, T & s2) { return !(s1 == s2); }
+
+    template<typename T> friend typename libreoffice_internal::CharPtrDetector<T, bool>::TypeUtf16
+    operator !=(T const & s1, OUString const & s2) { return !(s1 == s2); }
+
+    template<typename T>
+    friend typename libreoffice_internal::NonConstCharArrayDetector<T, bool>::TypeUtf16
+    operator !=(T & s1, OUString const & s2) { return !(s1 == s2); }
+
+#else
+
+    friend bool     operator == ( const OUString& rStr1,    const sal_Unicode * pStr2 )
+                        { return rStr1.compareTo( pStr2 ) == 0; }
+    friend bool     operator == ( const sal_Unicode * pStr1,    const OUString& rStr2 )
+                        { return OUString( pStr1 ).compareTo( rStr2 ) == 0; }
+
+    friend bool     operator != ( const OUString& rStr1,    const sal_Unicode * pStr2 )
+                        { return !(operator == ( rStr1, pStr2 )); }
+    friend bool     operator != ( const sal_Unicode * pStr1,    const OUString& rStr2 )
+                        { return !(operator == ( pStr1, rStr2 )); }
+
+#endif
+
     /**
      * Compare string to an ASCII string literal.
      *
diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
index 5b215584792d..0faf69ee9d87 100644
--- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx
+++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx
@@ -646,12 +646,10 @@ void Test::testMiscEquivalent()
 void Test::testParser()
 {
     OUString sOutput;
-    OUString sInput(u"{ \U0001D44E }"); // non-BMP Unicode
-    OUString sExpected(u"\U0001D44E");
-    auto pNode = SmParser().ParseExpression(sInput);
+    auto pNode = SmParser().ParseExpression(u"{ \U0001D44E }"); // non-BMP Unicode
     pNode->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0);
     SmNodeToTextVisitor(pNode.get(), sOutput);
-    CPPUNIT_ASSERT_EQUAL(sExpected, sOutput);
+    CPPUNIT_ASSERT_EQUAL(OUString(u"\U0001D44E"), sOutput);
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
diff --git a/svtools/source/misc/sampletext.cxx b/svtools/source/misc/sampletext.cxx
index b87c1250a4eb..b1638d0907d6 100644
--- a/svtools/source/misc/sampletext.cxx
+++ b/svtools/source/misc/sampletext.cxx
@@ -162,14 +162,14 @@ OUString makeShortRepresentativeSymbolTextForSelectedFont(OutputDevice const &rD
     {
         static const sal_Unicode aImplAppleSymbolText[] = {
             0x03BC, 0x2202, 0x2211, 0x220F, 0x03C0, 0x222B, 0x03A9, 0x221A, 0};
-        OUString sSampleText(aImplAppleSymbolText);
-        bool bHasSampleTextGlyphs = (-1 == rDevice.HasGlyphs(rDevice.GetFont(), sSampleText));
+        bool bHasSampleTextGlyphs
+            = (-1 == rDevice.HasGlyphs(rDevice.GetFont(), aImplAppleSymbolText));
         //It's the Apple version
         if (bHasSampleTextGlyphs)
-            return OUString(aImplAppleSymbolText);
+            return aImplAppleSymbolText;
         static const sal_Unicode aImplAdobeSymbolText[] = {
             0xF06D, 0xF0B6, 0xF0E5, 0xF0D5, 0xF070, 0xF0F2, 0xF057, 0xF0D6, 0};
-        return OUString(aImplAdobeSymbolText);
+        return aImplAdobeSymbolText;
     }
 
     const bool bOpenSymbol = IsStarSymbol(rDevice.GetFont().GetFamilyName());
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index b893cad50a70..9cd64eebf6f6 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -241,15 +241,13 @@ DECLARE_RTFEXPORT_TEST(testMathD, "math-d.rtf")
 DECLARE_RTFEXPORT_TEST(testMathEscaping, "math-escaping.rtf")
 {
     OUString aActual = getFormula(getRun(getParagraph(1), 1));
-    OUString aExpected(u"\u00E1 \\{");
-    CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
+    CPPUNIT_ASSERT_EQUAL(OUString(u"\u00E1 \\{"), aActual);
 }
 
 DECLARE_RTFEXPORT_TEST(testMathLim, "math-lim.rtf")
 {
     OUString aActual = getFormula(getRun(getParagraph(1), 1));
-    OUString aExpected(u"lim from {x \u2192 1} {x}");
-    CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
+    CPPUNIT_ASSERT_EQUAL(OUString(u"lim from {x \u2192 1} {x}"), aActual);
 }
 
 DECLARE_RTFEXPORT_TEST(testMathMatrix, "math-matrix.rtf")
@@ -404,8 +402,7 @@ DECLARE_RTFEXPORT_TEST(testFdo77979, "fdo77979.odt")
 {
     CPPUNIT_ASSERT_EQUAL(1, getPages());
     // font name is encoded with \fcharset of font
-    OUString aExpected(u"\u5FAE\u8F6F\u96C5\u9ED1");
-    CPPUNIT_ASSERT_EQUAL(aExpected,
+    CPPUNIT_ASSERT_EQUAL(OUString(u"\u5FAE\u8F6F\u96C5\u9ED1"),
                          getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
 }
 
@@ -501,8 +498,8 @@ DECLARE_RTFEXPORT_TEST(testFdo61507, "fdo61507.rtf")
         mxComponent, uno::UNO_QUERY);
     uno::Reference<document::XDocumentProperties> xDocumentProperties(
         xDocumentPropertiesSupplier->getDocumentProperties());
-    OUString aExpected(u"\u00C9\u00C1\u0150\u0170\u222D");
-    CPPUNIT_ASSERT_EQUAL(aExpected, xDocumentProperties->getTitle());
+    CPPUNIT_ASSERT_EQUAL(OUString(u"\u00C9\u00C1\u0150\u0170\u222D"),
+                         xDocumentProperties->getTitle());
 
     // Only "Hello.", no additional characters.
     CPPUNIT_ASSERT_EQUAL(6, getLength());
@@ -533,9 +530,10 @@ DECLARE_RTFEXPORT_TEST(testMnor, "mnor.rtf")
 {
     // \mnor wasn't handled, leading to missing quotes around "divF" and so on.
     OUString aActual = getFormula(getRun(getParagraph(1), 1));
-    OUString aExpected(
-        u"iiint from {V} to <?> {\"divF\"} dV = llint from {S} to <?> {\"F\" \u2219 \"n\" dS}");
-    CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
+    CPPUNIT_ASSERT_EQUAL(
+        OUString(
+            u"iiint from {V} to <?> {\"divF\"} dV = llint from {S} to <?> {\"F\" \u2219 \"n\" dS}"),
+        aActual);
 }
 
 DECLARE_RTFEXPORT_TEST(testI120928, "i120928.rtf")
diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx b/sw/qa/extras/rtfexport/rtfexport2.cxx
index 9025bdc44781..bde4a109d687 100644
--- a/sw/qa/extras/rtfexport/rtfexport2.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport2.cxx
@@ -261,8 +261,7 @@ DECLARE_RTFEXPORT_TEST(testFdo45394, "fdo45394.rtf")
         getStyles("PageStyles")->getByName("Standard"), "HeaderText");
     OUString aActual = xHeaderText->getString();
     // Encoding in the header was wrong.
-    OUString aExpected(u"\u041F\u041A \u0420\u0418\u041A");
-    CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
+    CPPUNIT_ASSERT_EQUAL(OUString(u"\u041F\u041A \u0420\u0418\u041A"), aActual);
 
     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
     uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(),
@@ -328,8 +327,9 @@ DECLARE_RTFEXPORT_TEST(testFdo48023, "fdo48023.rtf")
     uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
 
     // Implicit encoding detection based on locale was missing
-    OUString aExpected(u"\u041F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0438\u0441\u0442");
-    CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
+    CPPUNIT_ASSERT_EQUAL(
+        OUString(u"\u041F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0438\u0441\u0442"),
+        xTextRange->getString());
 }
 
 DECLARE_RTFEXPORT_TEST(testFdo48876, "fdo48876.rtf")
@@ -350,8 +350,7 @@ DECLARE_RTFEXPORT_TEST(testFdo44211, "fdo44211.rtf")
 {
     uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
 
-    OUString aExpected(u"\u0105\u010D\u0119");
-    CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString(u"\u0105\u010D\u0119"), xTextRange->getString());
 }
 
 DECLARE_RTFEXPORT_TEST(testFdo48037, "fdo48037.rtf")
@@ -531,11 +530,7 @@ DECLARE_RTFEXPORT_TEST(testFdo36089, "fdo36089.rtf")
                          getProperty<sal_Int16>(getRun(getParagraph(1), 2), "CharEscapement"));
 }
 
-DECLARE_RTFEXPORT_TEST(testFdo48446, "fdo48446.rtf")
-{
-    OUString aExpected(u"\u0418\u043C\u044F");
-    getParagraph(1, aExpected);
-}
+DECLARE_RTFEXPORT_TEST(testFdo48446, "fdo48446.rtf") { getParagraph(1, u"\u0418\u043C\u044F"); }
 
 DECLARE_RTFEXPORT_TEST(testFdo47495, "fdo47495.rtf")
 {
@@ -736,8 +731,8 @@ DECLARE_RTFEXPORT_TEST(testFdo56512, "fdo56512.rtf")
     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(),
                                                          uno::UNO_QUERY);
     uno::Reference<text::XTextRange> xTextRange(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
-    OUString aExpected(u"\u05E2\u05D5\u05E1\u05E7 \u05DE\u05D5\u05E8\u05E9\u05D4 ");
-    CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString(u"\u05E2\u05D5\u05E1\u05E7 \u05DE\u05D5\u05E8\u05E9\u05D4 "),
+                         xTextRange->getString());
 }
 
 DECLARE_RTFEXPORT_TEST(testFdo52989, "fdo52989.rtf")
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx
index db0771f54984..aa043ecfc750 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -327,8 +327,7 @@ DECLARE_RTFEXPORT_TEST(testFdo44715, "fdo44715.rtf")
 DECLARE_RTFEXPORT_TEST(testFdo68076, "fdo68076.rtf")
 {
     // Encoding of the last char was wrong (more 'o' than 'y').
-    OUString aExpected(u"\u041E\u0431\u044A\u0435\u043A\u0442 \u2013 \u0443");
-    getParagraph(1, aExpected);
+    getParagraph(1, u"\u041E\u0431\u044A\u0435\u043A\u0442 \u2013 \u0443");
 }
 
 DECLARE_RTFEXPORT_TEST(testFdo70221, "fdo70221.rtf")
@@ -563,16 +562,14 @@ DECLARE_RTFEXPORT_TEST(testDprectAnchor, "dprect-anchor.rtf")
 
 DECLARE_RTFEXPORT_TEST(testFdo76628, "fdo76628.rtf")
 {
-    OUString aExpected(u"\u041E\u0411\u0420\u0410\u0417\u0415\u0426");
     // Should be 'SAMPLE' in Russian, was garbage.
-    getParagraph(1, aExpected);
+    getParagraph(1, u"\u041E\u0411\u0420\u0410\u0417\u0415\u0426");
 
     uno::Reference<text::XText> xHeaderText = getProperty<uno::Reference<text::XText>>(
         getStyles("PageStyles")->getByName("Standard"), "HeaderText");
-    OUString aExpectedHeader(
-        u"\u041F\u043E\u0434\u0433\u043E\u0442\u043E\u0432\u043B\u0435\u043D\u043E");
     // Should be 'prepared' in Russian, was garbage.
-    getParagraphOfText(1, xHeaderText, aExpectedHeader);
+    getParagraphOfText(1, xHeaderText,
+                       u"\u041F\u043E\u0434\u0433\u043E\u0442\u043E\u0432\u043B\u0435\u043D\u043E");
 }
 
 DECLARE_RTFEXPORT_TEST(testFdo77267, "fdo77267.rtf")
@@ -731,30 +728,26 @@ DECLARE_RTFEXPORT_TEST(testFdo85889pc, "fdo85889-pc.rtf")
 {
     uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
 
-    OUString aExpected(u"\u00B1\u2265\u2264");
-    CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString(u"\u00B1\u2265\u2264"), xTextRange->getString());
 }
 
 DECLARE_RTFEXPORT_TEST(testFdo85889pca, "fdo85889-pca.rtf")
 {
     uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
 
-    OUString aExpected(u"\u00B1\u2017\u00BE");
-    CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString(u"\u00B1\u2017\u00BE"), xTextRange->getString());
 }
 
 DECLARE_RTFEXPORT_TEST(testFdo85889mac, "fdo85889-mac.rtf")
 {
     uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
 
-    OUString aExpected(u"\u00D2\u00DA\u00DB");
-    CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString(u"\u00D2\u00DA\u00DB"), xTextRange->getString());
 }
 
 DECLARE_RTFEXPORT_TEST(testFdo72031, "fdo72031.rtf")
 {
-    OUString aExpected(u"\uF0C5");
-    CPPUNIT_ASSERT_EQUAL(aExpected, getRun(getParagraph(1), 1)->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString(u"\uF0C5"), getRun(getParagraph(1), 1)->getString());
 }
 
 DECLARE_RTFEXPORT_TEST(testFdo86750, "fdo86750.rtf")
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index c3fc3df4f15b..3c6e6cb370e4 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -266,8 +266,8 @@ CPPUNIT_TEST_FIXTURE(Test, testFdo45182)
     uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes();
     uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
     // Encoding in the footnote was wrong.
-    OUString aExpected(u"\u017Eivnost\u00ED" SAL_NEWLINE_STRING);
-    CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString(u"\u017Eivnost\u00ED" SAL_NEWLINE_STRING),
+                         xTextRange->getString());
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testFdo85812)
@@ -841,8 +841,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf105511)
     DefaultLocale::set("ru-RU", batch);
     batch->commit();
     load(mpTestDocumentPath, "tdf105511.rtf");
-    OUString aExpected(u"\u0418\u043C\u044F");
-    getParagraph(1, aExpected);
+    getParagraph(1, u"\u0418\u043C\u044F");
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testContSectionPageBreak)
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 181e2c8c1e88..34fd549c9948 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -4498,8 +4498,8 @@ void SwUiWriterTest::testTdf89954()
     SwNodeIndex aNodeIndex(pDoc->GetNodes().GetEndOfContent(), -1);
     // Placeholder character for the comment anchor was ^A (CH_TXTATR_BREAKWORD), not <fff9> (CH_TXTATR_INWORD).
     // As a result, autocorrect did not turn the 't' input into 'T'.
-    OUString aExpected(u"Tes\uFFF9t. Test.");
-    CPPUNIT_ASSERT_EQUAL(aExpected, aNodeIndex.GetNode().GetTextNode()->GetText());
+    CPPUNIT_ASSERT_EQUAL(
+        OUString(u"Tes\uFFF9t. Test."), aNodeIndex.GetNode().GetTextNode()->GetText());
 }
 
 void SwUiWriterTest::testTdf89720()
@@ -7377,8 +7377,8 @@ void SwUiWriterTest::testTdf106164()
     const sal_Unicode cChar = ' ';
     pWrtShell->AutoCorrect(corr, cChar);
     sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
-    OUString sReplaced(u"We\u2019re ");
-    CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+    CPPUNIT_ASSERT_EQUAL(
+        OUString(u"We\u2019re "), static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
 }
 
 void SwUiWriterTest::testTdf54409()
@@ -7434,8 +7434,8 @@ void SwUiWriterTest::testTdf59666()
     const sal_Unicode cChar = ' ';
     pWrtShell->AutoCorrect(corr, cChar);
     sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
-    OUString sReplaced(u"\u03C0 ");
-    CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+    CPPUNIT_ASSERT_EQUAL(
+        OUString(u"\u03C0 "), static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
 }
 
 void SwUiWriterTest::testTdf133524()
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 607d89f8b630..96dce4aff82a 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1194,12 +1194,12 @@ void PdfExportTest::testTdf115117_2a()
     int nChars = FPDFText_CountChars(pPdfTextPage);
     CPPUNIT_ASSERT_EQUAL(13, nChars);
 
-    OUString aExpectedText = u"\u0627\u0644 \u0628\u0627\u0644 \u0648\u0642\u0641 \u0627\u0644";
     std::vector<sal_uInt32> aChars(nChars);
     for (int i = 0; i < nChars; i++)
         aChars[i] = FPDFText_GetUnicode(pPdfTextPage, i);
     OUString aActualText(aChars.data(), aChars.size());
-    CPPUNIT_ASSERT_EQUAL(aExpectedText, aActualText);
+    CPPUNIT_ASSERT_EQUAL(
+        OUString(u"\u0627\u0644 \u0628\u0627\u0644 \u0648\u0642\u0641 \u0627\u0644"), aActualText);
 
     FPDFText_ClosePage(pPdfTextPage);
 #endif


More information about the Libreoffice-commits mailing list