[Libreoffice-commits] core.git: sax/qa

Stephan Bergmann sbergman at redhat.com
Tue Aug 16 10:20:16 UTC 2016


 sax/qa/cppunit/xmlimport.cxx |   30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

New commits:
commit 174c064b0409de94472a5a46f29f740525513506
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Aug 16 12:19:52 2016 +0200

    loplugin:stringstatic
    
    Change-Id: I3812abe3b275bc1b89e340d0e8f52aa1d67905e8

diff --git a/sax/qa/cppunit/xmlimport.cxx b/sax/qa/cppunit/xmlimport.cxx
index c50a674..457f5f1 100644
--- a/sax/qa/cppunit/xmlimport.cxx
+++ b/sax/qa/cppunit/xmlimport.cxx
@@ -270,9 +270,9 @@ class DummyTokenHandler : public cppu::WeakImplHelper< XFastTokenHandler >,
                           public sax_fastparser::FastTokenHandlerBase
 {
 public:
-    const static OUString tokens[];
-    const static OUString namespaceURIs[];
-    const static OUString namespacePrefixes[];
+    const static OString tokens[];
+    const static OUStringLiteral namespaceURIs[];
+    const static OString namespacePrefixes[];
 
     // XFastTokenHandler
     virtual Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 nToken )
@@ -283,15 +283,15 @@ public:
     virtual sal_Int32 getTokenDirect( const char *pToken, sal_Int32 nLength ) const override;
 };
 
-const OUString DummyTokenHandler::tokens[] = { "Signature", "CanonicalizationMethod", "Algorithm", "Type",
+const OString DummyTokenHandler::tokens[] = { "Signature", "CanonicalizationMethod", "Algorithm", "Type",
                                               "DigestMethod", "Reference", "document",
                                               "spacing", "Player", "Height" };
 
-const OUString DummyTokenHandler::namespaceURIs[] = { "http://www.w3.org/2000/09/xmldsig#",
-                                                  "http://schemas.openxmlformats.org/wordprocessingml/2006/main/",
-                                                  "xyzsports.com/players/football/" };
+const OUStringLiteral DummyTokenHandler::namespaceURIs[] = { OUStringLiteral("http://www.w3.org/2000/09/xmldsig#"),
+                                                  OUStringLiteral("http://schemas.openxmlformats.org/wordprocessingml/2006/main/"),
+                                                  OUStringLiteral("xyzsports.com/players/football/") };
 
-const OUString DummyTokenHandler::namespacePrefixes[] = { "", "w", "Player" };
+const OString DummyTokenHandler::namespacePrefixes[] = { "", "w", "Player" };
 
 Sequence< sal_Int8 > DummyTokenHandler::getUTF8Identifier( sal_Int32 nToken )
     throw (uno::RuntimeException, std::exception)
@@ -300,14 +300,14 @@ Sequence< sal_Int8 > DummyTokenHandler::getUTF8Identifier( sal_Int32 nToken )
     if ( ( ( nToken & 0xffff0000 ) != 0 ) ) //namespace
     {
         sal_uInt32 nNamespaceToken = ( nToken >> 16 ) - 1;
-        if ( nNamespaceToken < sizeof( namespacePrefixes ) / sizeof( OUString ) )
-            aUtf8Token = OUStringToOString( namespacePrefixes[ nNamespaceToken ], RTL_TEXTENCODING_UTF8 );
+        if ( nNamespaceToken < SAL_N_ELEMENTS(namespacePrefixes) )
+            aUtf8Token = namespacePrefixes[ nNamespaceToken ];
     }
     else //element or attribute
     {
         sal_uInt32 nElementToken = nToken & 0xffff;
-        if ( nElementToken < sizeof( tokens ) / sizeof( OUString ) )
-            aUtf8Token = OUStringToOString( tokens[ nElementToken ], RTL_TEXTENCODING_UTF8 );
+        if ( nElementToken < SAL_N_ELEMENTS(tokens) )
+            aUtf8Token = tokens[ nElementToken ];
     }
     Sequence< sal_Int8 > aSeq = Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >(
                 aUtf8Token.getStr() ), aUtf8Token.getLength() );
@@ -323,8 +323,8 @@ sal_Int32 DummyTokenHandler::getTokenFromUTF8( const uno::Sequence< sal_Int8 >&
 
 sal_Int32 DummyTokenHandler::getTokenDirect( const char* pToken, sal_Int32 nLength ) const
 {
-    OUString sToken( pToken, nLength, RTL_TEXTENCODING_UTF8 );
-    for( sal_uInt16  i = 0; i < sizeof(tokens)/sizeof(OUString); i++ )
+    OString sToken( pToken, nLength );
+    for( sal_uInt16  i = 0; i < SAL_N_ELEMENTS(tokens); i++ )
     {
         if ( tokens[i] == sToken )
             return (sal_Int32)i;
@@ -376,7 +376,7 @@ void XMLImportTest::setUp()
     args[0] <<= xTokenHandler;
     xInit->initialize( args );
 
-    sal_Int32 nNamespaceCount = sizeof( DummyTokenHandler::namespaceURIs ) / sizeof( OUString );
+    sal_Int32 nNamespaceCount = SAL_N_ELEMENTS(DummyTokenHandler::namespaceURIs);
     uno::Sequence<uno::Any> namespaceArgs( nNamespaceCount + 1 );
     namespaceArgs[0] <<= OUString( "registerNamespaces" );
     for (sal_Int32 i = 1; i <= nNamespaceCount; i++ )


More information about the Libreoffice-commits mailing list