[Libreoffice-commits] .: 2 commits - comphelper/inc comphelper/qa comphelper/source sc/source

Caolán McNamara caolan at kemper.freedesktop.org
Fri Feb 10 03:09:40 PST 2012


 comphelper/inc/comphelper/string.hxx |   30 +++++++++++++++++++++++
 comphelper/qa/string/test_string.cxx |   44 +++++++++++++++++++++++++++++++++++
 comphelper/source/misc/string.cxx    |   15 +++++++++++
 sc/source/ui/docshell/docsh.cxx      |    6 ++--
 4 files changed, 92 insertions(+), 3 deletions(-)

New commits:
commit 39bfd6c0bcce78a13eda4566741be3ae06152cb1
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Feb 10 11:08:51 2012 +0000

    can use direct operator[] variants

diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 87568d9..d02d9d4 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -349,7 +349,7 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet)
                                 xub_StrLen nIndex = nNameLength - nLinkTabNameLength;
                                 INetURLObject aINetURLObject(aDocURLBuffer.makeStringAndClear());
                                 if( String(aName).Equals(String(aLinkTabName), nIndex, nLinkTabNameLength) &&
-                                    (aName.getStr()[nIndex - 1] == '#') && // before the table name should be the # char
+                                    (aName[nIndex - 1] == '#') && // before the table name should be the # char
                                     !aINetURLObject.HasError()) // the docname should be a valid URL
                                 {
                                     aName = ScGlobal::GetDocTabName( aDocument.GetLinkDoc( i ), aDocument.GetLinkTab( i ) );
@@ -1947,9 +1947,9 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
             rtl::OUString aUniString = aString;//remove that later
             if (!bString && cStrDelim != 0 && !aUniString.isEmpty())
             {
-                sal_Unicode c = aUniString.getStr()[0];
+                sal_Unicode c = aUniString[0];
                 bString = (c == cStrDelim || c == ' ' ||
-                        aUniString.getStr()[aUniString.getLength()-1] == ' ' ||
+                        aUniString[aUniString.getLength()-1] == ' ' ||
                         aUniString.indexOf(cStrDelim) >= 0);
                 if (!bString && cDelim != 0)
                     bString = (aUniString.indexOf(cDelim) >= 0);
commit 9c19e79f19f0dbd55def4a0cf473248ea91e188e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Feb 10 11:08:21 2012 +0000

    extend unit test to islower

diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx
index 3fba475..e3d11d9 100644
--- a/comphelper/inc/comphelper/string.hxx
+++ b/comphelper/inc/comphelper/string.hxx
@@ -593,6 +593,16 @@ COMPHELPER_DLLPUBLIC bool isdigitAsciiString(const rtl::OUString &rString);
  */
 COMPHELPER_DLLPUBLIC bool isalnumAsciiString(const rtl::OString &rString);
 
+/** Determine if an OUString contains solely ASCII alphanumeric chars/digits
+
+    @param rString  An OUString
+
+    @return         false if string contains any characters outside
+                    the ASCII 'a'-'z', 'A'-'Z' and '0'-'9' ranges
+                    true otherwise, including for empty string
+ */
+COMPHELPER_DLLPUBLIC bool isalnumAsciiString(const rtl::OUString &rString);
+
 /** Determine if an OString contains solely ASCII lower-case chars
 
     @param rString  An OString
@@ -603,6 +613,16 @@ COMPHELPER_DLLPUBLIC bool isalnumAsciiString(const rtl::OString &rString);
  */
 COMPHELPER_DLLPUBLIC bool islowerAsciiString(const rtl::OString &rString);
 
+/** Determine if an OUString contains solely ASCII lower-case chars
+
+    @param rString  An OUString
+
+    @return         false if string contains any characters outside
+                    the ASCII 'a'-'z' ranges
+                    true otherwise, including for empty string
+ */
+COMPHELPER_DLLPUBLIC bool islowerAsciiString(const rtl::OUString &rString);
+
 /** Determine if an OString contains solely ASCII upper-case chars
 
     @param rString  An OString
@@ -613,6 +633,16 @@ COMPHELPER_DLLPUBLIC bool islowerAsciiString(const rtl::OString &rString);
  */
 COMPHELPER_DLLPUBLIC bool isupperAsciiString(const rtl::OString &rString);
 
+/** Determine if an OUString contains solely ASCII upper-case chars
+
+    @param rString  An OUString
+
+    @return         false if string contains any characters outside
+                    the ASCII 'A'-'Z' ranges
+                    true otherwise, including for empty string
+ */
+COMPHELPER_DLLPUBLIC bool isupperAsciiString(const rtl::OUString &rString);
+
 COMPHELPER_DLLPUBLIC inline bool isdigitAscii(sal_Unicode c)
 {
     return ((c >= '0') && (c <= '9'));
diff --git a/comphelper/qa/string/test_string.cxx b/comphelper/qa/string/test_string.cxx
index 1fb8922..82eaee0 100644
--- a/comphelper/qa/string/test_string.cxx
+++ b/comphelper/qa/string/test_string.cxx
@@ -57,6 +57,7 @@ public:
     void testIsdigitAsciiString();
     void testIsalnumAsciiString();
     void testIsupperAsciiString();
+    void testIslowerAsciiString();
     void testIndexOfL();
     void testMatchIgnoreAsciiCaseL();
 
@@ -74,6 +75,7 @@ public:
     CPPUNIT_TEST(testIsdigitAsciiString);
     CPPUNIT_TEST(testIsalnumAsciiString);
     CPPUNIT_TEST(testIsupperAsciiString);
+    CPPUNIT_TEST(testIslowerAsciiString);
     CPPUNIT_TEST(testIndexOfL);
     CPPUNIT_TEST(testMatchIgnoreAsciiCaseL);
     CPPUNIT_TEST_SUITE_END();
@@ -146,6 +148,18 @@ void TestString::testIsalnumAsciiString()
 
     rtl::OString s4(RTL_CONSTASCII_STRINGPARAM("1A[4"));
     CPPUNIT_ASSERT_EQUAL(comphelper::string::isalnumAsciiString(s4), false);
+
+    rtl::OUString s5(RTL_CONSTASCII_USTRINGPARAM("1234"));
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::isalnumAsciiString(s5), true);
+
+    rtl::OUString s6(RTL_CONSTASCII_USTRINGPARAM("1A34"));
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::isalnumAsciiString(s6), true);
+
+    rtl::OUString s7;
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::isalnumAsciiString(s7), true);
+
+    rtl::OUString s8(RTL_CONSTASCII_USTRINGPARAM("1A[4"));
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::isalnumAsciiString(s8), false);
 }
 
 void TestString::testIsupperAsciiString()
@@ -158,6 +172,36 @@ void TestString::testIsupperAsciiString()
 
     rtl::OString s3(RTL_CONSTASCII_STRINGPARAM("AABB"));
     CPPUNIT_ASSERT_EQUAL(comphelper::string::isupperAsciiString(s3), true);
+
+    rtl::OUString s4(RTL_CONSTASCII_USTRINGPARAM("1234"));
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::isupperAsciiString(s4), false);
+
+    rtl::OUString s5(RTL_CONSTASCII_USTRINGPARAM("aAbB"));
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::isupperAsciiString(s5), false);
+
+    rtl::OUString s6(RTL_CONSTASCII_USTRINGPARAM("AABB"));
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::isupperAsciiString(s6), true);
+}
+
+void TestString::testIslowerAsciiString()
+{
+    rtl::OString s1(RTL_CONSTASCII_STRINGPARAM("1234"));
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::islowerAsciiString(s1), false);
+
+    rtl::OString s2(RTL_CONSTASCII_STRINGPARAM("aAbB"));
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::islowerAsciiString(s2), false);
+
+    rtl::OString s3(RTL_CONSTASCII_STRINGPARAM("aabb"));
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::islowerAsciiString(s3), true);
+
+    rtl::OUString s4(RTL_CONSTASCII_USTRINGPARAM("1234"));
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::islowerAsciiString(s4), false);
+
+    rtl::OUString s5(RTL_CONSTASCII_USTRINGPARAM("aAbB"));
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::islowerAsciiString(s5), false);
+
+    rtl::OUString s6(RTL_CONSTASCII_USTRINGPARAM("aabb"));
+    CPPUNIT_ASSERT_EQUAL(comphelper::string::islowerAsciiString(s6), true);
 }
 
 void TestString::testIndexOfL()
diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx
index 712d903..13a1236 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -516,6 +516,11 @@ bool isalnumAsciiString(const rtl::OString &rString)
     return tmpl_is_OPER_AsciiString<isalnumAscii>(rString);
 }
 
+bool isalnumAsciiString(const rtl::OUString &rString)
+{
+    return tmpl_is_OPER_AsciiString<isalnumAscii>(rString);
+}
+
 bool isdigitAsciiString(const rtl::OString &rString)
 {
     return tmpl_is_OPER_AsciiString<isdigitAscii>(rString);
@@ -531,11 +536,21 @@ bool islowerAsciiString(const rtl::OString &rString)
     return tmpl_is_OPER_AsciiString<islowerAscii>(rString);
 }
 
+bool islowerAsciiString(const rtl::OUString &rString)
+{
+    return tmpl_is_OPER_AsciiString<islowerAscii>(rString);
+}
+
 bool isupperAsciiString(const rtl::OString &rString)
 {
     return tmpl_is_OPER_AsciiString<isupperAscii>(rString);
 }
 
+bool isupperAsciiString(const rtl::OUString &rString)
+{
+    return tmpl_is_OPER_AsciiString<isupperAscii>(rString);
+}
+
 } }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list