[Libreoffice-commits] .: 13 commits - comphelper/inc comphelper/source editeng/source i18npool/source i18nutil/source sal/inc sal/qa sal/rtl sal/util sw/source tools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Dec 6 04:35:44 PST 2012


 comphelper/inc/comphelper/string.hxx                               |   45 ----
 comphelper/source/misc/string.cxx                                  |   37 ---
 editeng/source/editeng/editdoc.cxx                                 |    2 
 editeng/source/editeng/editobj.cxx                                 |    2 
 editeng/source/items/flditem.cxx                                   |    1 
 i18npool/source/characterclassification/cclass_unicode.cxx         |    2 
 i18npool/source/nativenumber/nativenumbersupplier.cxx              |    2 
 i18npool/source/textconversion/textconversion_zh.cxx               |    2 
 i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx  |    2 
 i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx      |    2 
 i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx   |    2 
 i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx |    2 
 i18npool/source/transliteration/transliteration_Ignore.cxx         |    2 
 i18npool/source/transliteration/transliteration_Numeric.cxx        |    2 
 i18npool/source/transliteration/transliteration_OneToOne.cxx       |    2 
 i18npool/source/transliteration/transliteration_body.cxx           |    4 
 i18nutil/source/utility/widthfolding.cxx                           |    4 
 sal/inc/rtl/strbuf.hxx                                             |   36 ++-
 sal/inc/rtl/string.h                                               |   42 ++++
 sal/inc/rtl/string.hxx                                             |   62 ++++--
 sal/inc/rtl/stringconcat.hxx                                       |   17 +
 sal/inc/rtl/ustrbuf.hxx                                            |   38 +++
 sal/inc/rtl/ustring.h                                              |   43 ++++
 sal/inc/rtl/ustring.hxx                                            |   78 ++++---
 sal/qa/rtl/strings/test_ostring_concat.cxx                         |   92 ++++++++-
 sal/qa/rtl/strings/test_ostring_stringliterals.cxx                 |   12 -
 sal/qa/rtl/strings/test_oustring_concat.cxx                        |  102 +++++++++-
 sal/rtl/source/strtmpl.cxx                                         |   35 +++
 sal/util/sal.map                                                   |    8 
 sw/source/core/edit/edglss.cxx                                     |    1 
 sw/source/core/unocore/unoobj.cxx                                  |    2 
 sw/source/filter/ww8/ww8par.cxx                                    |    2 
 tools/source/stream/stream.cxx                                     |    4 
 33 files changed, 496 insertions(+), 193 deletions(-)

New commits:
commit 8cf32d61a75b1dbb496b38cd95c54b972aea183f
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Dec 6 13:33:18 2012 +0100

    int vs oslInterlockedCount ambiguity
    
    Change-Id: I096b1232427ad6996e0b2cfafc9ba38386e19208

diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx b/sal/qa/rtl/strings/test_ostring_concat.cxx
index a2b172c..6708960 100644
--- a/sal/qa/rtl/strings/test_ostring_concat.cxx
+++ b/sal/qa/rtl/strings/test_ostring_concat.cxx
@@ -60,7 +60,7 @@ CPPUNIT_TEST_SUITE_END();
 void test::ostring::StringConcat::checkConcat()
 {
 // All the extra () are to protect commas againsts being treated as separators of macro arguments.
-    CPPUNIT_ASSERT_EQUAL( OString(), OString(OString() + OString()) );
+    CPPUNIT_ASSERT_EQUAL( OString(), OString(OString() + OString()));
     CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OString( "foo" ) + OString( "bar" )));
     TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OString, OString > )), typeid( OString( "foo" ) + OString( "bar" )));
     CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OString( "foo" ) + "bar" ));
@@ -93,33 +93,33 @@ void test::ostring::StringConcat::checkEnsureCapacity()
     rtl_String* str = NULL;
     rtl_string_newFromLiteral( &str, "test", strlen( "test" ), 0 );
     CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length );
-    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    CPPUNIT_ASSERT_EQUAL( 1, int( str->refCount ));
 
     rtl_String* oldStr = str;
     rtl_string_ensureCapacity( &str, 4 ); // should be no-op
     CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length );
-    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    CPPUNIT_ASSERT_EQUAL( 1, int( str->refCount ));
     CPPUNIT_ASSERT( oldStr == str );
 
     rtl_string_acquire( oldStr );
-    CPPUNIT_ASSERT_EQUAL( 2, str->refCount );
+    CPPUNIT_ASSERT_EQUAL( 2, int( str->refCount ));
     rtl_string_ensureCapacity( &str, 4 );
     CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length );
-    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    CPPUNIT_ASSERT_EQUAL( 1, int( str->refCount ));
     // a copy was forced because of refcount
     CPPUNIT_ASSERT( oldStr != str );
     CPPUNIT_ASSERT( strcmp( oldStr->buffer, str->buffer ) == 0 );
-    CPPUNIT_ASSERT_EQUAL( 1, oldStr->refCount );
+    CPPUNIT_ASSERT_EQUAL( 1, int( oldStr->refCount ));
     rtl_string_release( str );
     str = oldStr;
 
     rtl_string_acquire( oldStr );
     rtl_string_ensureCapacity( &str, 1024 );
     CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length ); // size is still 4
-    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    CPPUNIT_ASSERT_EQUAL( 1, int( str->refCount ));
     CPPUNIT_ASSERT( oldStr != str );
     CPPUNIT_ASSERT( strcmp( oldStr->buffer, str->buffer ) == 0 );
-    CPPUNIT_ASSERT_EQUAL( 1, oldStr->refCount );
+    CPPUNIT_ASSERT_EQUAL( 1, int( oldStr->refCount ));
     strcpy( str->buffer, "01234567890123456789" ); // but there should be extra capacity
     str->length += 20;
     rtl_string_release( str );
diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx b/sal/qa/rtl/strings/test_oustring_concat.cxx
index c5b5497..9cde7b8 100644
--- a/sal/qa/rtl/strings/test_oustring_concat.cxx
+++ b/sal/qa/rtl/strings/test_oustring_concat.cxx
@@ -60,7 +60,7 @@ CPPUNIT_TEST_SUITE_END();
 void test::oustring::StringConcat::checkConcat()
 {
 // All the extra () are to protect commas againsts being treated as separators of macro arguments.
-    CPPUNIT_ASSERT_EQUAL( OUString(), OUString(OUString() + OUString()) );
+    CPPUNIT_ASSERT_EQUAL( OUString(), OUString(OUString() + OUString()));
     CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString( "foo" ) + OUString( "bar" )));
     TYPES_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, OUString > )), typeid( OUString( "foo" ) + OUString( "bar" )));
     CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUString( "foo" ) + "bar" ));
@@ -81,33 +81,33 @@ void test::oustring::StringConcat::checkEnsureCapacity()
     rtl_uString* str = NULL;
     rtl_uString_newFromLiteral( &str, "test", strlen( "test" ), 0 );
     CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length );
-    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    CPPUNIT_ASSERT_EQUAL( 1, int( str->refCount ));
 
     rtl_uString* oldStr = str;
     rtl_uString_ensureCapacity( &str, 4 ); // should be no-op
     CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length );
-    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    CPPUNIT_ASSERT_EQUAL( 1, int( str->refCount ));
     CPPUNIT_ASSERT( oldStr == str );
 
     rtl_uString_acquire( oldStr );
-    CPPUNIT_ASSERT_EQUAL( 2, str->refCount );
+    CPPUNIT_ASSERT_EQUAL( 2, int( str->refCount ));
     rtl_uString_ensureCapacity( &str, 4 );
     CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length );
-    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    CPPUNIT_ASSERT_EQUAL( 1, int( str->refCount ));
     // a copy was forced because of refcount
     CPPUNIT_ASSERT( oldStr != str );
     CPPUNIT_ASSERT( rtl_ustr_compare( oldStr->buffer, str->buffer ) == 0 );
-    CPPUNIT_ASSERT_EQUAL( 1, oldStr->refCount );
+    CPPUNIT_ASSERT_EQUAL( 1, int( oldStr->refCount ));
     rtl_uString_release( str );
     str = oldStr;
 
     rtl_uString_acquire( oldStr );
     rtl_uString_ensureCapacity( &str, 1024 );
     CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length ); // size is still 4
-    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    CPPUNIT_ASSERT_EQUAL( 1, int( str->refCount ));
     CPPUNIT_ASSERT( oldStr != str );
     CPPUNIT_ASSERT( rtl_ustr_compare( oldStr->buffer, str->buffer ) == 0 );
-    CPPUNIT_ASSERT_EQUAL( 1, oldStr->refCount );
+    CPPUNIT_ASSERT_EQUAL( 1, int( oldStr->refCount ));
     // but there should be extra capacity
     for( int i = 0;
          i < 20;
commit f0d75874c3106b9e25e36ff338c7935813ad0c11
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Dec 5 21:55:29 2012 +0100

    unittest for fast string operator+ not allowing unwanted combinations
    
    Change-Id: I5891efcec7db373407a661636108fd979839db52

diff --git a/sal/inc/rtl/stringconcat.hxx b/sal/inc/rtl/stringconcat.hxx
index 2b4fc31..a6e3467 100644
--- a/sal/inc/rtl/stringconcat.hxx
+++ b/sal/inc/rtl/stringconcat.hxx
@@ -260,6 +260,23 @@ typename internal::Enable< OUStringConcat< T1, T2 >, ToStringHelper< T1 >::allow
     return OUStringConcat< T1, T2 >( left, right );
     }
 
+#ifdef RTL_STRING_UNITTEST_CONCAT
+// Special overload to catch the remaining invalid combinations. The helper struct must
+// be used to make this operator+ overload a worse choice than all the existing overloads above.
+struct StringConcatInvalid
+    {
+    template< typename T >
+    StringConcatInvalid( const T& ) {}
+    };
+template< typename T >
+inline
+int operator+( const StringConcatInvalid&, const T& )
+    {
+    rtl_string_unittest_invalid_concat = true;
+    return 0; // doesn't matter
+    }
+#endif
+
 } // namespace
 
 #endif
diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx b/sal/qa/rtl/strings/test_ostring_concat.cxx
index 4c0630c..a2b172c 100644
--- a/sal/qa/rtl/strings/test_ostring_concat.cxx
+++ b/sal/qa/rtl/strings/test_ostring_concat.cxx
@@ -7,12 +7,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+// activate support for detecting errors instead of getting compile errors
+#define RTL_STRING_UNITTEST_CONCAT
+bool rtl_string_unittest_invalid_concat = false;
+
 #include <sal/types.h>
 #include <cppunit/TestFixture.h>
 #include <cppunit/extensions/HelperMacros.h>
 
 #include <rtl/string.hxx>
 #include <rtl/strbuf.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
 
 #include <typeinfo>
 
@@ -36,11 +42,13 @@ private:
     void checkConcat();
     void checkEnsureCapacity();
     void checkAppend();
+    void checkInvalid();
 
 CPPUNIT_TEST_SUITE(StringConcat);
 CPPUNIT_TEST(checkConcat);
 CPPUNIT_TEST(checkEnsureCapacity);
 CPPUNIT_TEST(checkAppend);
+CPPUNIT_TEST(checkInvalid);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -75,6 +83,8 @@ void test::ostring::StringConcat::checkConcat()
     TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OString, const char* > )), typeid( OString( "foo" ) + d3 ));
     CPPUNIT_ASSERT_EQUAL( OString( "fooabc" ), OString( OString( "foo" ) + d4 ));
     TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OString, char* > )), typeid( OString( "foo" ) + d4 ));
+    CPPUNIT_ASSERT_EQUAL( OString( "foobar" ), OString( OStringBuffer( "foo" ) + OString( "bar" )));
+    TYPES_ASSERT_EQUAL(( typeid( OStringConcat< OStringBuffer, OString > )), typeid( OStringBuffer( "foo" ) + OString( "bar" )));
 }
 #undef typeid
 
@@ -126,6 +136,27 @@ void test::ostring::StringConcat::checkAppend()
     CPPUNIT_ASSERT_EQUAL( OString( "foobarbaz" ), buf.makeStringAndClear());
 }
 
+#define INVALID_CONCAT( expression ) \
+    ( \
+    rtl_string_unittest_invalid_concat = false, \
+    ( void ) OString( expression ), \
+    rtl_string_unittest_invalid_concat )
+
+void test::ostring::StringConcat::checkInvalid()
+{
+#ifdef RTL_FAST_STRING
+    CPPUNIT_ASSERT( !INVALID_CONCAT( OString() + OString()));
+    CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUString( "b" )));
+    CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUStringBuffer( "b" )));
+    CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + OUStringLiteral( "b" )));
+    CPPUNIT_ASSERT( INVALID_CONCAT( OString( "a" ) + 1 ));
+    rtl_String* rs = NULL;
+    rtl_uString* rus = NULL;
+    CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rs ));
+    CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rus ));
+#endif
+}
+
 }} // namespace
 
 CPPUNIT_TEST_SUITE_REGISTRATION(test::ostring::StringConcat);
diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx b/sal/qa/rtl/strings/test_oustring_concat.cxx
index 8d98232..c5b5497 100644
--- a/sal/qa/rtl/strings/test_oustring_concat.cxx
+++ b/sal/qa/rtl/strings/test_oustring_concat.cxx
@@ -7,12 +7,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+// activate support for detecting errors instead of getting compile errors
+#define RTL_STRING_UNITTEST_CONCAT
+extern bool rtl_string_unittest_invalid_concat;
+
 #include <sal/types.h>
 #include <cppunit/TestFixture.h>
 #include <cppunit/extensions/HelperMacros.h>
 
 #include <rtl/ustring.hxx>
 #include <rtl/ustrbuf.hxx>
+#include <rtl/string.hxx>
+#include <rtl/strbuf.hxx>
 
 #include <typeinfo>
 
@@ -36,11 +42,13 @@ private:
     void checkConcat();
     void checkEnsureCapacity();
     void checkAppend();
+    void checkInvalid();
 
 CPPUNIT_TEST_SUITE(StringConcat);
 CPPUNIT_TEST(checkConcat);
 CPPUNIT_TEST(checkEnsureCapacity);
 CPPUNIT_TEST(checkAppend);
+CPPUNIT_TEST(checkInvalid);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -64,6 +72,8 @@ void test::oustring::StringConcat::checkConcat()
     const char d1[] = "xyz";
     CPPUNIT_ASSERT_EQUAL( OUString( "fooxyz" ), OUString( OUString( "foo" ) + d1 ));
     TYPES_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( OUString( "foo" ) + d1 ));
+    CPPUNIT_ASSERT_EQUAL( OUString( "foobar" ), OUString( OUStringBuffer( "foo" ) + OUString( "bar" )));
+    TYPES_ASSERT_EQUAL(( typeid( OUStringConcat< OUStringBuffer, OUString > )), typeid( OUStringBuffer( "foo" ) + OUString( "bar" )));
 }
 
 void test::oustring::StringConcat::checkEnsureCapacity()
@@ -118,6 +128,32 @@ void test::oustring::StringConcat::checkAppend()
     CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), buf.makeStringAndClear());
 }
 
+#define INVALID_CONCAT( expression ) \
+    ( \
+    rtl_string_unittest_invalid_concat = false, \
+    ( void ) OUString( expression ), \
+    rtl_string_unittest_invalid_concat )
+
+void test::oustring::StringConcat::checkInvalid()
+{
+#ifdef RTL_FAST_STRING
+    CPPUNIT_ASSERT( !INVALID_CONCAT( OUString() + OUString()));
+    CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OString( "b" )));
+    CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OStringBuffer( "b" )));
+    CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + (const char*) "b" ));
+    char d[] = "b";
+    CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + d ));
+    CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + (char*)d ));
+    CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + OStringLiteral( "b" )));
+    CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "a" ) + 1 ));
+    rtl_String* rs = NULL;
+    rtl_uString* rus = NULL;
+    CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rs ));
+    CPPUNIT_ASSERT( INVALID_CONCAT( OUString( "b" ) + rus ));
+#endif
+
+}
+
 }} // namespace
 
 CPPUNIT_TEST_SUITE_REGISTRATION(test::oustring::StringConcat);
commit 9b7ec76111ed966e93f6e0802aa6c8e021dcd4a8
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Dec 5 00:55:13 2012 +0100

    use rtl_(u)string_alloc where the contents clearly don't need to be cleared
    
    Change-Id: I3e8d8f123aaa43ee3721fae6f220a8c5f959a0ea

diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx
index 90204f0..86f89ef 100644
--- a/sal/inc/rtl/strbuf.hxx
+++ b/sal/inc/rtl/strbuf.hxx
@@ -233,13 +233,11 @@ public:
     OStringBuffer( const OStringConcat< T1, T2 >& c )
     {
         const sal_Int32 l = c.length();
-        rtl_String* buffer = NULL;
         nCapacity = l + 16;
-        rtl_string_new_WithLength( &buffer, nCapacity );
-        char* end = c.addData( buffer->buffer );
+        pData = rtl_string_alloc( nCapacity );
+        char* end = c.addData( pData->buffer );
         *end = '\0';
-        buffer->length = end - buffer->buffer;
-        pData = buffer;
+        pData->length = end - pData->buffer;
     }
 #endif
 
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index 1ef0860..8e33973 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -265,14 +265,13 @@ public:
     OString( const OStringConcat< T1, T2 >& c )
     {
         const sal_Int32 l = c.length();
-        rtl_String* buffer = NULL;
-        rtl_string_new_WithLength( &buffer, l );
+        pData = rtl_string_alloc( l );
         if (l != 0)
         {
-            char* end = c.addData( buffer->buffer );
-            buffer->length = end - buffer->buffer;
+            char* end = c.addData( pData->buffer );
+            pData->length = end - pData->buffer;
+            *end = '\0';
         }
-        pData = buffer;
     }
 #endif
 
diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx
index 9549414..c5c6f5d 100644
--- a/sal/inc/rtl/ustrbuf.hxx
+++ b/sal/inc/rtl/ustrbuf.hxx
@@ -225,14 +225,12 @@ public:
     OUStringBuffer( const OUStringConcat< T1, T2 >& c )
     {
         const sal_Int32 l = c.length();
-        rtl_uString* buffer = NULL;
         nCapacity = l + 16;
-        rtl_uString_new_WithLength( &buffer, nCapacity ); // TODO this clears, not necessary
-        sal_Unicode* end = c.addData( buffer->buffer );
+        pData = rtl_uString_alloc( nCapacity );
+        sal_Unicode* end = c.addData( pData->buffer );
         *end = '\0';
-        buffer->length = end - buffer->buffer;
-        // TODO realloc in case buffer->length is noticeably smaller than l ?
-        pData = buffer;
+        pData->length = end - pData->buffer;
+        // TODO realloc in case pData->>length is noticeably smaller than l ?
     }
 #endif
     /** Assign to this a copy of value.
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index 07294f4..bd1b9cb 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -333,15 +333,14 @@ public:
     OUString( const OUStringConcat< T1, T2 >& c )
     {
         const sal_Int32 l = c.length();
-        rtl_uString* buffer = NULL;
-        rtl_uString_new_WithLength( &buffer, l ); // TODO this clears, not necessary
+        pData = rtl_uString_alloc( l );
         if (l != 0)
         {
-            sal_Unicode* end = c.addData( buffer->buffer );
-            buffer->length = end - buffer->buffer;
-            // TODO realloc in case buffer->length is noticeably smaller than l?
+            sal_Unicode* end = c.addData( pData->buffer );
+            pData->length = end - pData->buffer;
+            *end = '\0';
+            // TODO realloc in case pData->length is noticeably smaller than l?
         }
-        pData = buffer;
     }
 #endif
 
commit 81e16cea9a11185c209894973db8d1990fa9cce6
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Dec 5 00:37:01 2012 +0100

    mvoe rtl_(u)string_alloc to sal
    
    No point in hidding something useful like this in some helper lib.
    
    Change-Id: I7332d7f6bd428378cd19e7e95ad130771a541140

diff --git a/comphelper/inc/comphelper/string.hxx b/comphelper/inc/comphelper/string.hxx
index 693703d..cfa9ddd 100644
--- a/comphelper/inc/comphelper/string.hxx
+++ b/comphelper/inc/comphelper/string.hxx
@@ -37,51 +37,6 @@
 // go into the stable URE API:
 namespace comphelper { namespace string {
 
-/** Allocate a new string containing space for a given number of characters.
-
-    The reference count of the new string will be 1. The length of the string
-    will be nLen. This function throws std::bad_alloc on out-of-memory
-    conditions.
-
-    The characters of the capacity are not cleared, and the length is set to
-    nLen, unlike the similar method of rtl_uString_new_WithLength which
-    zeros out the buffer, and sets the length to 0. So should be somewhat
-    more efficient for allocating a new string.
-
-    call rtl_uString_release to release the string
-    alternatively pass ownership to an OUString with
-    rtl::OUString(newStr, SAL_NO_ACQUIRE);
-
-    @param newStr
-    pointer to the new string.
-
-    @param len
-    the number of characters.
- */
-COMPHELPER_DLLPUBLIC rtl_uString * SAL_CALL rtl_uString_alloc(sal_Int32 nLen);
-
-/** Allocate a new string containing space for a given number of characters.
-
-    The reference count of the new string will be 1. The length of the string
-    will be nLen. This function does not handle out-of-memory conditions.
-
-    The characters of the capacity are not cleared, and the length is set to
-    nLen, unlike the similar method of rtl_String_new_WithLength which
-    zeros out the buffer, and sets the length to 0. So should be somewhat
-    more efficient for allocating a new string.
-
-    call rtl_String_release to release the string
-    alternatively pass ownership to an OUString with
-    rtl::OUString(newStr, SAL_NO_ACQUIRE);
-
-    @param newStr
-    pointer to the new string.
-
-    @param len
-    the number of characters.
- */
-COMPHELPER_DLLPUBLIC rtl_String * SAL_CALL rtl_string_alloc(sal_Int32 nLen);
-
 /** Compare an OString to a single char
 
     @param rIn      The input OString
diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx
index 1dae9e8..0674f9a 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -377,43 +377,6 @@ bool isdigitAsciiString(const rtl::OUString &rString)
 
 namespace
 {
-    template <typename T, typename U> T* string_alloc(sal_Int32 nLen)
-    {
-        //Clearly this is somewhat cosy with the sal implmentation
-
-        //rtl_[u]String contains U buffer[1], so an input of nLen
-        //allocates a buffer of nLen + 1 and we'll ensure a null termination
-
-        T* newStr =
-            (sal::static_int_cast< sal_uInt32 >(nLen)
-               <= ((SAL_MAX_UINT32 - sizeof (T))
-                   / sizeof (U)))
-            ? (T*) rtl_allocateMemory(
-                sizeof (T) + nLen * sizeof (U))
-            : NULL;
-
-        if (!newStr)
-            throw std::bad_alloc();
-
-        newStr->refCount = 1;
-        newStr->length = nLen;
-        newStr->buffer[nLen] = 0;
-        return newStr;
-    }
-}
-
-rtl_uString * SAL_CALL rtl_uString_alloc(sal_Int32 nLen)
-{
-    return string_alloc<rtl_uString, sal_Unicode>(nLen);
-}
-
-rtl_String * SAL_CALL rtl_string_alloc(sal_Int32 nLen)
-{
-    return string_alloc<rtl_String, sal_Char>(nLen);
-}
-
-namespace
-{
     template <typename T, typename O> T tmpl_reverseString(const T &rIn)
     {
         if (rIn.isEmpty())
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 80556b9..9b96ed7 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2052,7 +2052,7 @@ XubString EditDoc::GetText( LineEnd eEnd ) const
     if ( nSepSize )
         nLen += (nNodes - 1) * nSepSize;
 
-    rtl_uString* newStr = comphelper::string::rtl_uString_alloc(nLen);
+    rtl_uString* newStr = rtl_uString_alloc(nLen);
     sal_Unicode* pCur = newStr->buffer;
     size_t nLastNode = nNodes-1;
     for ( sal_uInt16 nNode = 0; nNode < nNodes; nNode++ )
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 669f003..275aa77 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -1435,8 +1435,6 @@ void BinTextObject::CreateData( SvStream& rIStream )
         rIStream >> bUnicodeStrings;
         if ( bUnicodeStrings )
         {
-            using comphelper::string::rtl_uString_alloc;
-
             for ( sal_uInt16 nPara = 0; nPara < nParagraphs; nPara++ )
             {
                 ContentInfo& rC = aContents[nPara];
diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx
index c9eebe6..1c0a2c1 100644
--- a/editeng/source/items/flditem.cxx
+++ b/editeng/source/items/flditem.cxx
@@ -557,7 +557,6 @@ static rtl::OUString read_unicode( SvPersistStream & rStm )
     rStm >> nL;
     if ( nL )
     {
-        using comphelper::string::rtl_uString_alloc;
         pStr = rtl_uString_alloc(nL);
         //endian specific?, yipes!
         rStm.Read(pStr->buffer, nL*sizeof(sal_Unicode));
diff --git a/i18npool/source/characterclassification/cclass_unicode.cxx b/i18npool/source/characterclassification/cclass_unicode.cxx
index 5e27fa5..045de39 100644
--- a/i18npool/source/characterclassification/cclass_unicode.cxx
+++ b/i18npool/source/characterclassification/cclass_unicode.cxx
@@ -88,7 +88,7 @@ cclass_Unicode::toTitle( const OUString& Text, sal_Int32 nPos, sal_Int32 nCount,
         nCount = len - nPos;
 
     trans->setMappingType(MappingTypeToTitle, rLocale);
-    rtl_uString* pStr = comphelper::string::rtl_uString_alloc(nCount);
+    rtl_uString* pStr = rtl_uString_alloc(nCount);
     sal_Unicode* out = pStr->buffer;
     BreakIteratorImpl brk(m_xContext);
     Boundary bdy = brk.getWordBoundary(Text, nPos, rLocale,
diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx
index 8632b5d..bda3f87 100644
--- a/i18npool/source/nativenumber/nativenumbersupplier.cxx
+++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx
@@ -68,7 +68,7 @@ OUString SAL_CALL AsciiToNativeChar( const OUString& inStr, sal_Int32 startPos,
         Sequence< sal_Int32 >& offset, sal_Bool useOffset, sal_Int16 number ) throw(RuntimeException)
 {
         const sal_Unicode *src = inStr.getStr() + startPos;
-        rtl_uString *newStr = comphelper::string::rtl_uString_alloc(nCount);
+        rtl_uString *newStr = rtl_uString_alloc(nCount);
         if (useOffset)
             offset.realloc(nCount);
 
diff --git a/i18npool/source/textconversion/textconversion_zh.cxx b/i18npool/source/textconversion/textconversion_zh.cxx
index a6d842f..54ae5d3 100644
--- a/i18npool/source/textconversion/textconversion_zh.cxx
+++ b/i18npool/source/textconversion/textconversion_zh.cxx
@@ -110,7 +110,7 @@ TextConversion_zh::getCharConversion(const OUString& aText, sal_Int32 nStartPos,
     }
 #endif
 
-    rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nLength);
+    rtl_uString * newStr = rtl_uString_alloc(nLength);
     for (sal_Int32 i = 0; i < nLength; i++)
         newStr->buffer[i] =
             getOneCharConversion(aText[nStartPos+i], Data, Index);
diff --git a/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx b/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx
index 1bd9a55..07d56e2 100644
--- a/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreIandEfollowedByYa_ja_JP.cxx
@@ -76,7 +76,7 @@ ignoreIandEfollowedByYa_ja_JP::folding( const OUString& inStr, sal_Int32 startPo
 {
     // Create a string buffer which can hold nCount + 1 characters.
     // The reference count is 1 now.
-    rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
+    rtl_uString * newStr = rtl_uString_alloc(nCount);
     sal_Unicode * dst = newStr->buffer;
     const sal_Unicode * src = inStr.getStr() + startPos;
 
diff --git a/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx b/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx
index e1c2953..57c1b1c 100644
--- a/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreIterationMark_ja_JP.cxx
@@ -91,7 +91,7 @@ ignoreIterationMark_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, s
 
     // Create a string buffer which can hold nCount + 1 characters.
     // The reference count is 1 now.
-    rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
+    rtl_uString * newStr = rtl_uString_alloc(nCount);
     sal_Unicode * dst = newStr->buffer;
     const sal_Unicode * src = inStr.getStr() + startPos;
 
diff --git a/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx b/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx
index 913a3cf..977f471 100644
--- a/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreKiKuFollowedBySa_ja_JP.cxx
@@ -36,7 +36,7 @@ ignoreKiKuFollowedBySa_ja_JP::folding( const OUString& inStr, sal_Int32 startPos
 {
     // Create a string buffer which can hold nCount + 1 characters.
     // The reference count is 1 now.
-    rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
+    rtl_uString * newStr = rtl_uString_alloc(nCount);
     sal_Unicode * dst = newStr->buffer;
     const sal_Unicode * src = inStr.getStr() + startPos;
 
diff --git a/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx b/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx
index 6b5636a..66f45c5 100644
--- a/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx
+++ b/i18npool/source/transliteration/ignoreProlongedSoundMark_ja_JP.cxx
@@ -298,7 +298,7 @@ ignoreProlongedSoundMark_ja_JP::folding( const OUString& inStr, sal_Int32 startP
 {
     // Create a string buffer which can hold nCount + 1 characters.
     // The reference count is 1 now.
-    rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
+    rtl_uString * newStr = rtl_uString_alloc(nCount);
     sal_Unicode * dst = newStr->buffer;
     const sal_Unicode * src = inStr.getStr() + startPos;
 
diff --git a/i18npool/source/transliteration/transliteration_Ignore.cxx b/i18npool/source/transliteration/transliteration_Ignore.cxx
index 0d7e883..0300ea4 100644
--- a/i18npool/source/transliteration/transliteration_Ignore.cxx
+++ b/i18npool/source/transliteration/transliteration_Ignore.cxx
@@ -126,7 +126,7 @@ transliteration_Ignore::folding( const OUString& inStr, sal_Int32 startPos,
 {
     // Create a string buffer which can hold nCount + 1 characters.
     // The reference count is 1 now.
-    rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
+    rtl_uString * newStr = rtl_uString_alloc(nCount);
     sal_Unicode * dst = newStr->buffer;
     const sal_Unicode * src = inStr.getStr() + startPos;
 
diff --git a/i18npool/source/transliteration/transliteration_Numeric.cxx b/i18npool/source/transliteration/transliteration_Numeric.cxx
index eec4236..329f2d5 100644
--- a/i18npool/source/transliteration/transliteration_Numeric.cxx
+++ b/i18npool/source/transliteration/transliteration_Numeric.cxx
@@ -68,7 +68,7 @@ transliteration_Numeric::transliterateBullet( const OUString& inStr, sal_Int32 s
         if (endPos >  inStr.getLength())
             endPos = inStr.getLength();
 
-        rtl_uString* pStr = comphelper::string::rtl_uString_alloc(nCount);
+        rtl_uString* pStr = rtl_uString_alloc(nCount);
         sal_Unicode* out = pStr->buffer;
 
         if (useOffset)
diff --git a/i18npool/source/transliteration/transliteration_OneToOne.cxx b/i18npool/source/transliteration/transliteration_OneToOne.cxx
index df9916a..f62a7fb 100644
--- a/i18npool/source/transliteration/transliteration_OneToOne.cxx
+++ b/i18npool/source/transliteration/transliteration_OneToOne.cxx
@@ -63,7 +63,7 @@ transliteration_OneToOne::transliterate( const OUString& inStr, sal_Int32 startP
 {
     // Create a string buffer which can hold nCount + 1 characters.
     // The reference count is 1 now.
-    rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
+    rtl_uString * newStr = rtl_uString_alloc(nCount);
     sal_Unicode * dst = newStr->buffer;
     const sal_Unicode * src = inStr.getStr() + startPos;
 
diff --git a/i18npool/source/transliteration/transliteration_body.cxx b/i18npool/source/transliteration/transliteration_body.cxx
index c1ed6b8..db3ba0a 100644
--- a/i18npool/source/transliteration/transliteration_body.cxx
+++ b/i18npool/source/transliteration/transliteration_body.cxx
@@ -119,7 +119,7 @@ Transliteration_body::transliterate(
             const Mapping &map = casefolding::getValue( in, i, nCount, aLocale, nTmpMappingType );
             nOffCount += map.nmap;
         }
-        rtl_uString* pStr = comphelper::string::rtl_uString_alloc(nOffCount);
+        rtl_uString* pStr = rtl_uString_alloc(nOffCount);
         sal_Unicode* out = pStr->buffer;
 
         if ( nOffCount != offset.getLength() )
@@ -189,7 +189,7 @@ OUString SAL_CALL
 Transliteration_body::transliterateChar2String( sal_Unicode inChar ) throw(RuntimeException)
 {
         const Mapping &map = casefolding::getValue(&inChar, 0, 1, aLocale, nMappingType);
-        rtl_uString* pStr = comphelper::string::rtl_uString_alloc(map.nmap);
+        rtl_uString* pStr = rtl_uString_alloc(map.nmap);
         sal_Unicode* out = pStr->buffer;
         sal_Int32 i;
 
diff --git a/i18nutil/source/utility/widthfolding.cxx b/i18nutil/source/utility/widthfolding.cxx
index 6288881..0777c97 100644
--- a/i18nutil/source/utility/widthfolding.cxx
+++ b/i18nutil/source/utility/widthfolding.cxx
@@ -47,7 +47,7 @@ OUString widthfolding::decompose_ja_voiced_sound_marks (const OUString& inStr, s
   // Create a string buffer which can hold nCount * 2 + 1 characters.
   // Its size may become double of nCount.
   // The reference count is 1 now.
-  rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount * 2);
+  rtl_uString * newStr = rtl_uString_alloc(nCount * 2);
 
   sal_Int32 *p = NULL;
   sal_Int32 position = 0;
@@ -109,7 +109,7 @@ OUString widthfolding::compose_ja_voiced_sound_marks (const OUString& inStr, sal
   // Create a string buffer which can hold nCount + 1 characters.
   // Its size may become equal to nCount or smaller.
   // The reference count is 1 now.
-  rtl_uString * newStr = comphelper::string::rtl_uString_alloc(nCount);
+  rtl_uString * newStr = rtl_uString_alloc(nCount);
 
   // Prepare pointers of unicode character arrays.
   const sal_Unicode* src = inStr.getStr() + startPos;
diff --git a/sal/inc/rtl/string.h b/sal/inc/rtl/string.h
index 13c622d..bfeecf7 100644
--- a/sal/inc/rtl/string.h
+++ b/sal/inc/rtl/string.h
@@ -818,6 +818,30 @@ SAL_DLLPUBLIC void SAL_CALL rtl_string_new( rtl_String ** newStr ) SAL_THROW_EXT
 
 /** Allocate a new string containing space for a given number of characters.
 
+    The reference count of the new string will be 1. The length of the string
+    will be nLen. This function does not handle out-of-memory conditions.
+
+    The characters of the capacity are not cleared, and the length is set to
+    nLen, unlike the similar method of rtl_String_new_WithLength which
+    zeros out the buffer, and sets the length to 0. So should be somewhat
+    more efficient for allocating a new string.
+
+    call rtl_String_release to release the string
+    alternatively pass ownership to an OUString with
+    rtl::OUString(newStr, SAL_NO_ACQUIRE);
+
+    @param newStr
+    pointer to the new string.
+
+    @param len
+    the number of characters.
+
+    @since LibreOffice 4.1
+ */
+SAL_DLLPUBLIC rtl_String * SAL_CALL rtl_string_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string containing space for a given number of characters.
+
     If len is greater than zero, the reference count of the new string will be
     1.  The values of all characters are set to 0 and the length of the string
     is 0.  This function does not handle out-of-memory conditions.
diff --git a/sal/inc/rtl/ustring.h b/sal/inc/rtl/ustring.h
index 0548033..fe2f2f4 100644
--- a/sal/inc/rtl/ustring.h
+++ b/sal/inc/rtl/ustring.h
@@ -1151,6 +1151,31 @@ SAL_DLLPUBLIC void SAL_CALL rtl_uString_new(
 
 /** Allocate a new string containing space for a given number of characters.
 
+    The reference count of the new string will be 1. The length of the string
+    will be nLen. This function throws std::bad_alloc on out-of-memory
+    conditions.
+
+    The characters of the capacity are not cleared, and the length is set to
+    nLen, unlike the similar method of rtl_uString_new_WithLength which
+    zeros out the buffer, and sets the length to 0. So should be somewhat
+    more efficient for allocating a new string.
+
+    call rtl_uString_release to release the string
+    alternatively pass ownership to an OUString with
+    rtl::OUString(newStr, SAL_NO_ACQUIRE);
+
+    @param newStr
+    pointer to the new string.
+
+    @param len
+    the number of characters.
+
+    @since LibreOffice 4.1
+ */
+SAL_DLLPUBLIC rtl_uString * SAL_CALL rtl_uString_alloc(sal_Int32 nLen) SAL_THROW_EXTERN_C();
+
+/** Allocate a new string containing space for a given number of characters.
+
     If len is greater than zero, the reference count of the new string will be
     1.  The values of all characters are set to 0 and the length of the string
     is 0.  This function does not handle out-of-memory conditions.
diff --git a/sal/rtl/source/strtmpl.cxx b/sal/rtl/source/strtmpl.cxx
index ffe12ad..f715a58 100644
--- a/sal/rtl/source/strtmpl.cxx
+++ b/sal/rtl/source/strtmpl.cxx
@@ -1066,6 +1066,17 @@ void SAL_CALL IMPL_RTL_STRINGNAME( new )( IMPL_RTL_STRINGDATA** ppThis )
 
 /* ----------------------------------------------------------------------- */
 
+IMPL_RTL_STRINGDATA* SAL_CALL IMPL_RTL_STRINGNAME( alloc )( sal_Int32 nLen )
+    SAL_THROW_EXTERN_C()
+{
+    if ( nLen <= 0 )
+        return (IMPL_RTL_STRINGDATA*) (&IMPL_RTL_EMPTYSTRING);
+    else
+        return IMPL_RTL_STRINGNAME( ImplAlloc )( nLen );
+}
+
+/* ----------------------------------------------------------------------- */
+
 void SAL_CALL IMPL_RTL_STRINGNAME( new_WithLength )( IMPL_RTL_STRINGDATA** ppThis, sal_Int32 nLen )
     SAL_THROW_EXTERN_C()
 {
diff --git a/sal/util/sal.map b/sal/util/sal.map
index 1eef9c6..9d3f88b 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -656,6 +656,8 @@ LIBO_UDK_4.1 { # symbols available in >= LibO 4.1
     global:
         rtl_string_ensureCapacity;
         rtl_uString_ensureCapacity;
+        rtl_string_alloc;
+        rtl_uString_alloc;
 } LIBO_UDK_4.0;
 
 PRIVATE_1.0 {
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx
index 9125987..210ce3f 100644
--- a/sw/source/core/edit/edglss.cxx
+++ b/sw/source/core/edit/edglss.cxx
@@ -339,7 +339,6 @@ sal_Bool SwEditShell::GetSelectedText( String &rBuf, int nHndlParaBrk )
                     rBuf = rtl::OUString(p);
                 else
                 {
-                    using comphelper::string::rtl_uString_alloc;
                     rtl_uString *pStr = rtl_uString_alloc(lLen / sizeof( sal_Unicode ));
                     aStream.Seek( 0 );
                     aStream.ResetError();
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index a91286a..a4f8ea2 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -206,7 +206,7 @@ void SwUnoCursorHelper::GetTextFromPam(SwPaM & rPam, OUString & rBuffer)
             aStream.ResetError();
 
             long lUniLen = (lLen / sizeof( sal_Unicode ));
-            rtl_uString *pStr = comphelper::string::rtl_uString_alloc(lUniLen);
+            rtl_uString *pStr = rtl_uString_alloc(lUniLen);
             aStream.Read(pStr->buffer, lUniLen * sizeof(sal_Unicode));
             rBuffer = rtl::OUString(pStr, SAL_NO_ACQUIRE);
         }
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 22c49fd..e71b6c0 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2567,7 +2567,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs)
         RTL_TEXTENCODING_MS_1252;
 
     // allocate unicode string data
-    rtl_uString *pStr = comphelper::string::rtl_uString_alloc(nStrLen);
+    rtl_uString *pStr = rtl_uString_alloc(nStrLen);
     sal_Unicode* pBuffer = pStr->buffer;
     sal_Unicode* pWork = pBuffer;
 
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 6ca4d07..68c9dc9 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1970,8 +1970,6 @@ void SvDataCopyStream::Assign( const SvDataCopyStream& )
 //Create a OString of nLen bytes from rStream
 rtl::OString read_uInt8s_ToOString(SvStream& rStrm, sal_Size nLen)
 {
-    using comphelper::string::rtl_string_alloc;
-
     rtl_String *pStr = NULL;
     if (nLen)
     {
@@ -1997,8 +1995,6 @@ rtl::OString read_uInt8s_ToOString(SvStream& rStrm, sal_Size nLen)
 //Create a OUString of nLen sal_Unicodes from rStream
 rtl::OUString read_uInt16s_ToOUString(SvStream& rStrm, sal_Size nLen)
 {
-    using comphelper::string::rtl_uString_alloc;
-
     rtl_uString *pStr = NULL;
     if (nLen)
     {
commit f82a55ec476955d9d4467725a4ea3ce9e514d8dd
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Dec 5 00:23:01 2012 +0100

    acquire on the shared empty string does nothing
    
    Change-Id: I03a38c387044bda8cec6287ab41c6d202c496473

diff --git a/sal/rtl/source/strtmpl.cxx b/sal/rtl/source/strtmpl.cxx
index afeb2db..ffe12ad 100644
--- a/sal/rtl/source/strtmpl.cxx
+++ b/sal/rtl/source/strtmpl.cxx
@@ -1062,7 +1062,6 @@ void SAL_CALL IMPL_RTL_STRINGNAME( new )( IMPL_RTL_STRINGDATA** ppThis )
         IMPL_RTL_STRINGNAME( release )( *ppThis );
 
     *ppThis = (IMPL_RTL_STRINGDATA*) (&IMPL_RTL_EMPTYSTRING);
-    IMPL_RTL_AQUIRE( *ppThis );
 }
 
 /* ----------------------------------------------------------------------- */
commit dd23ac402f58e2c1596e68de91efbd81ee6f623b
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Dec 4 23:53:38 2012 +0100

    pass string by reference instead of by value
    
    Should not make that big difference, but still. Should not be BIC in practice
    because it's inline.
    
    Change-Id: I53ec7dec46356fb63b0f6f73579cff1ca8495fbf

diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx
index 286a862..90204f0 100644
--- a/sal/inc/rtl/strbuf.hxx
+++ b/sal/inc/rtl/strbuf.hxx
@@ -143,7 +143,7 @@ public:
 
         @param   value   the initial string value.
      */
-    OStringBuffer(OString value)
+    OStringBuffer(const OString& value)
         : pData(NULL)
         , nCapacity( value.getLength() + 16 )
     {
diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx
index 79af254..9549414 100644
--- a/sal/inc/rtl/ustrbuf.hxx
+++ b/sal/inc/rtl/ustrbuf.hxx
@@ -138,7 +138,7 @@ public:
 
         @param   value   the initial contents of the buffer.
      */
-    OUStringBuffer(OUString value)
+    OUStringBuffer(const OUString& value)
         : pData(NULL)
         , nCapacity( value.getLength() + 16 )
     {
commit 88c00598b2a0bae1bdfe88d4300afec2512183d8
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Dec 4 19:58:11 2012 +0100

    support for fast string operator+ in operator+=/append
    
    Not much point in building a string instance that will be copied elsewhere immediatelly.
    
    Change-Id: I38b7d3696f2c619e6424eb3959b00cd2c7738c47

diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx
index 77e588f..286a862 100644
--- a/sal/inc/rtl/strbuf.hxx
+++ b/sal/inc/rtl/strbuf.hxx
@@ -496,6 +496,25 @@ public:
         return *this;
     }
 
+#ifdef RTL_FAST_STRING
+    /**
+     @overload
+     @internal
+    */
+    template< typename T1, typename T2 >
+    OStringBuffer& append( const OStringConcat< T1, T2 >& c )
+    {
+        const int l = c.length();
+        if( l == 0 )
+            return *this;
+        rtl_stringbuffer_ensureCapacity( &pData, &nCapacity, pData->length + l );
+        char* end = c.addData( pData->buffer + pData->length );
+        *end = '\0';
+        pData->length = end - pData->buffer;
+        return *this;
+    }
+#endif
+
     /**
         Appends the string representation of the <code>sal_Bool</code>
         argument to the string buffer.
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index 2c73168..1ef0860 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -320,6 +320,24 @@ public:
         return *this;
     }
 
+#ifdef RTL_FAST_STRING
+    /**
+     @overload
+     @internal
+    */
+    template< typename T1, typename T2 >
+    OString& operator+=( const OStringConcat< T1, T2 >& c )
+    {
+        const int l = c.length();
+        if( l == 0 )
+            return *this;
+        rtl_string_ensureCapacity( &pData, pData->length + l );
+        char* end = c.addData( pData->buffer + pData->length );
+        *end = '\0';
+        pData->length = end - pData->buffer;
+        return *this;
+    }
+#endif
     /**
       Returns the length of this string.
 
diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx
index 9b986b6..79af254 100644
--- a/sal/inc/rtl/ustrbuf.hxx
+++ b/sal/inc/rtl/ustrbuf.hxx
@@ -494,6 +494,25 @@ public:
         return *this;
     }
 
+#ifdef RTL_FAST_STRING
+    /**
+     @overload
+     @internal
+    */
+    template< typename T1, typename T2 >
+    OUStringBuffer& append( const OUStringConcat< T1, T2 >& c )
+    {
+        const int l = c.length();
+        if( l == 0 )
+            return *this;
+        rtl_uStringbuffer_ensureCapacity( &pData, &nCapacity, pData->length + l );
+        sal_Unicode* end = c.addData( pData->buffer + pData->length );
+        *end = '\0';
+        pData->length = end - pData->buffer;
+        return *this;
+    }
+#endif
+
     /**
         Appends a 8-Bit ASCII character string to this string buffer.
 
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index dd7f0a4..07294f4 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -409,6 +409,25 @@ public:
         return *this;
     }
 
+#ifdef RTL_FAST_STRING
+    /**
+     @overload
+     @internal
+    */
+    template< typename T1, typename T2 >
+    OUString& operator+=( const OUStringConcat< T1, T2 >& c )
+    {
+        const int l = c.length();
+        if( l == 0 )
+            return *this;
+        rtl_uString_ensureCapacity( &pData, pData->length + l );
+        sal_Unicode* end = c.addData( pData->buffer + pData->length );
+        *end = '\0';
+        pData->length = end - pData->buffer;
+        return *this;
+    }
+#endif
+
     /**
       Returns the length of this string.
 
diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx b/sal/qa/rtl/strings/test_ostring_concat.cxx
index c3a422a..4c0630c 100644
--- a/sal/qa/rtl/strings/test_ostring_concat.cxx
+++ b/sal/qa/rtl/strings/test_ostring_concat.cxx
@@ -12,6 +12,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include <rtl/string.hxx>
+#include <rtl/strbuf.hxx>
 
 #include <typeinfo>
 
@@ -32,12 +33,14 @@ namespace test { namespace ostring {
 class StringConcat : public CppUnit::TestFixture
 {
 private:
-    void check();
+    void checkConcat();
     void checkEnsureCapacity();
+    void checkAppend();
 
 CPPUNIT_TEST_SUITE(StringConcat);
-CPPUNIT_TEST(check);
+CPPUNIT_TEST(checkConcat);
 CPPUNIT_TEST(checkEnsureCapacity);
+CPPUNIT_TEST(checkAppend);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -46,7 +49,7 @@ CPPUNIT_TEST_SUITE_END();
 #else
 #define TYPES_ASSERT_EQUAL( a, b )
 #endif
-void test::ostring::StringConcat::check()
+void test::ostring::StringConcat::checkConcat()
 {
 // All the extra () are to protect commas againsts being treated as separators of macro arguments.
     CPPUNIT_ASSERT_EQUAL( OString(), OString(OString() + OString()) );
@@ -113,6 +116,16 @@ void test::ostring::StringConcat::checkEnsureCapacity()
     rtl_string_release( oldStr );
 }
 
+void test::ostring::StringConcat::checkAppend()
+{
+    OString str( "foo" );
+    str += OStringLiteral( "bar" ) + "baz";
+    CPPUNIT_ASSERT_EQUAL( OString( "foobarbaz" ), str );
+    OStringBuffer buf( "foo" );
+    buf.append( OStringLiteral( "bar" ) + "baz" );
+    CPPUNIT_ASSERT_EQUAL( OString( "foobarbaz" ), buf.makeStringAndClear());
+}
+
 }} // namespace
 
 CPPUNIT_TEST_SUITE_REGISTRATION(test::ostring::StringConcat);
diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx b/sal/qa/rtl/strings/test_oustring_concat.cxx
index 108b166..8d98232 100644
--- a/sal/qa/rtl/strings/test_oustring_concat.cxx
+++ b/sal/qa/rtl/strings/test_oustring_concat.cxx
@@ -12,6 +12,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 #include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
 
 #include <typeinfo>
 
@@ -32,12 +33,14 @@ namespace test { namespace oustring {
 class StringConcat : public CppUnit::TestFixture
 {
 private:
-    void check();
+    void checkConcat();
     void checkEnsureCapacity();
+    void checkAppend();
 
 CPPUNIT_TEST_SUITE(StringConcat);
-CPPUNIT_TEST(check);
+CPPUNIT_TEST(checkConcat);
 CPPUNIT_TEST(checkEnsureCapacity);
+CPPUNIT_TEST(checkAppend);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -46,7 +49,7 @@ CPPUNIT_TEST_SUITE_END();
 #else
 #define TYPES_ASSERT_EQUAL( a, b )
 #endif
-void test::oustring::StringConcat::check()
+void test::oustring::StringConcat::checkConcat()
 {
 // All the extra () are to protect commas againsts being treated as separators of macro arguments.
     CPPUNIT_ASSERT_EQUAL( OUString(), OUString(OUString() + OUString()) );
@@ -105,6 +108,15 @@ void test::oustring::StringConcat::checkEnsureCapacity()
     rtl_uString_release( oldStr );
 }
 
+void test::oustring::StringConcat::checkAppend()
+{
+    OUString str( "foo" );
+    str += OUStringLiteral( "bar" ) + "baz";
+    CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), str );
+    OUStringBuffer buf( "foo" );
+    buf.append( OUStringLiteral( "bar" ) + "baz" );
+    CPPUNIT_ASSERT_EQUAL( OUString( "foobarbaz" ), buf.makeStringAndClear());
+}
 
 }} // namespace
 
commit b88a26f02276ec2e98287cd2e5f2abea1ea9e949
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Dec 4 19:27:34 2012 +0100

    rtl_(u)String_ensureCapacity
    
    Ensure there will be enough extra space in a string, to be used for string
    appending. A bit like rtl_(u)String_newConcat(), but without the function
    actually appending anything. Unlike the stringbuffer variant this does
    not allocate any extra.
    
    Change-Id: Ic6f84bf014a713f9912c81d8f1405c593978822d

diff --git a/sal/inc/rtl/string.h b/sal/inc/rtl/string.h
index 9f3c69a..13c622d 100644
--- a/sal/inc/rtl/string.h
+++ b/sal/inc/rtl/string.h
@@ -1313,6 +1313,24 @@ SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_convertUStringToString(
                                              sal_uInt32 nFlags)
     SAL_THROW_EXTERN_C();
 
+/** Ensure a string has enough space for a given number of characters.
+
+ If the given string is large enough and has refcount of 1, it is not altered in any way.
+ Otherwise it is replaced by a copy that has enough space for the given number of characters,
+ data from the source string is copied to the beginning of it, the content of the remaining
+ capacity undefined, the string has refcount of 1, and refcount of the original string is decreased.
+
+ @param str
+ pointer to the string.  The pointed-to data must be a valid string.
+
+ @param size
+ the number of characters
+
+ @since LibreOffice 4.1
+ @internal
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_string_ensureCapacity( rtl_String ** str, sal_Int32 size ) SAL_THROW_EXTERN_C();
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/sal/inc/rtl/ustring.h b/sal/inc/rtl/ustring.h
index 0352e59..0548033 100644
--- a/sal/inc/rtl/ustring.h
+++ b/sal/inc/rtl/ustring.h
@@ -1926,6 +1926,24 @@ SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_convertStringToUString(
     rtl_uString ** target, char const * source, sal_Int32 length,
     rtl_TextEncoding encoding, sal_uInt32 flags) SAL_THROW_EXTERN_C();
 
+/** Ensure a string has enough space for a given number of characters.
+
+ If the given string is large enough and has refcount of 1, it is not altered in any way.
+ Otherwise it is replaced by a copy that has enough space for the given number of characters,
+ data from the source string is copied to the beginning of it, the content of the remaining
+ capacity undefined, the string has refcount of 1, and refcount of the original string is decreased.
+
+ @param str
+ pointer to the string.  The pointed-to data must be a valid string.
+
+ @param size
+ the number of characters
+
+ @since LibreOffice 4.1
+ @internal
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_ensureCapacity( rtl_uString ** str, sal_Int32 size ) SAL_THROW_EXTERN_C();
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/sal/qa/rtl/strings/test_ostring_concat.cxx b/sal/qa/rtl/strings/test_ostring_concat.cxx
index 46457dd..c3a422a 100644
--- a/sal/qa/rtl/strings/test_ostring_concat.cxx
+++ b/sal/qa/rtl/strings/test_ostring_concat.cxx
@@ -33,9 +33,11 @@ class StringConcat : public CppUnit::TestFixture
 {
 private:
     void check();
+    void checkEnsureCapacity();
 
 CPPUNIT_TEST_SUITE(StringConcat);
 CPPUNIT_TEST(check);
+CPPUNIT_TEST(checkEnsureCapacity);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -73,6 +75,44 @@ void test::ostring::StringConcat::check()
 }
 #undef typeid
 
+void test::ostring::StringConcat::checkEnsureCapacity()
+{
+    rtl_String* str = NULL;
+    rtl_string_newFromLiteral( &str, "test", strlen( "test" ), 0 );
+    CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length );
+    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+
+    rtl_String* oldStr = str;
+    rtl_string_ensureCapacity( &str, 4 ); // should be no-op
+    CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length );
+    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    CPPUNIT_ASSERT( oldStr == str );
+
+    rtl_string_acquire( oldStr );
+    CPPUNIT_ASSERT_EQUAL( 2, str->refCount );
+    rtl_string_ensureCapacity( &str, 4 );
+    CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length );
+    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    // a copy was forced because of refcount
+    CPPUNIT_ASSERT( oldStr != str );
+    CPPUNIT_ASSERT( strcmp( oldStr->buffer, str->buffer ) == 0 );
+    CPPUNIT_ASSERT_EQUAL( 1, oldStr->refCount );
+    rtl_string_release( str );
+    str = oldStr;
+
+    rtl_string_acquire( oldStr );
+    rtl_string_ensureCapacity( &str, 1024 );
+    CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length ); // size is still 4
+    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    CPPUNIT_ASSERT( oldStr != str );
+    CPPUNIT_ASSERT( strcmp( oldStr->buffer, str->buffer ) == 0 );
+    CPPUNIT_ASSERT_EQUAL( 1, oldStr->refCount );
+    strcpy( str->buffer, "01234567890123456789" ); // but there should be extra capacity
+    str->length += 20;
+    rtl_string_release( str );
+    rtl_string_release( oldStr );
+}
+
 }} // namespace
 
 CPPUNIT_TEST_SUITE_REGISTRATION(test::ostring::StringConcat);
diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx b/sal/qa/rtl/strings/test_oustring_concat.cxx
index 7eefb6f..108b166 100644
--- a/sal/qa/rtl/strings/test_oustring_concat.cxx
+++ b/sal/qa/rtl/strings/test_oustring_concat.cxx
@@ -33,9 +33,11 @@ class StringConcat : public CppUnit::TestFixture
 {
 private:
     void check();
+    void checkEnsureCapacity();
 
 CPPUNIT_TEST_SUITE(StringConcat);
 CPPUNIT_TEST(check);
+CPPUNIT_TEST(checkEnsureCapacity);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -61,6 +63,49 @@ void test::oustring::StringConcat::check()
     TYPES_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( OUString( "foo" ) + d1 ));
 }
 
+void test::oustring::StringConcat::checkEnsureCapacity()
+{
+    rtl_uString* str = NULL;
+    rtl_uString_newFromLiteral( &str, "test", strlen( "test" ), 0 );
+    CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length );
+    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+
+    rtl_uString* oldStr = str;
+    rtl_uString_ensureCapacity( &str, 4 ); // should be no-op
+    CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length );
+    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    CPPUNIT_ASSERT( oldStr == str );
+
+    rtl_uString_acquire( oldStr );
+    CPPUNIT_ASSERT_EQUAL( 2, str->refCount );
+    rtl_uString_ensureCapacity( &str, 4 );
+    CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length );
+    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    // a copy was forced because of refcount
+    CPPUNIT_ASSERT( oldStr != str );
+    CPPUNIT_ASSERT( rtl_ustr_compare( oldStr->buffer, str->buffer ) == 0 );
+    CPPUNIT_ASSERT_EQUAL( 1, oldStr->refCount );
+    rtl_uString_release( str );
+    str = oldStr;
+
+    rtl_uString_acquire( oldStr );
+    rtl_uString_ensureCapacity( &str, 1024 );
+    CPPUNIT_ASSERT_EQUAL( sal_Int32( 4 ), str->length ); // size is still 4
+    CPPUNIT_ASSERT_EQUAL( 1, str->refCount );
+    CPPUNIT_ASSERT( oldStr != str );
+    CPPUNIT_ASSERT( rtl_ustr_compare( oldStr->buffer, str->buffer ) == 0 );
+    CPPUNIT_ASSERT_EQUAL( 1, oldStr->refCount );
+    // but there should be extra capacity
+    for( int i = 0;
+         i < 20;
+         ++i )
+        str->buffer[ str->length + i ] = '0';
+    str->length += 20;
+    rtl_uString_release( str );
+    rtl_uString_release( oldStr );
+}
+
+
 }} // namespace
 
 CPPUNIT_TEST_SUITE_REGISTRATION(test::oustring::StringConcat);
diff --git a/sal/rtl/source/strtmpl.cxx b/sal/rtl/source/strtmpl.cxx
index 8001e0a..afeb2db 100644
--- a/sal/rtl/source/strtmpl.cxx
+++ b/sal/rtl/source/strtmpl.cxx
@@ -1318,6 +1318,29 @@ void SAL_CALL IMPL_RTL_STRINGNAME( newConcat )( IMPL_RTL_STRINGDATA** ppThis,
 
 /* ----------------------------------------------------------------------- */
 
+void SAL_CALL IMPL_RTL_STRINGNAME( ensureCapacity )( IMPL_RTL_STRINGDATA** ppThis,
+                                                     sal_Int32 size )
+    SAL_THROW_EXTERN_C()
+{
+    IMPL_RTL_STRINGDATA* const pOrg = *ppThis;
+    if ( pOrg->refCount == 1 && pOrg->length >= size )
+        return;
+    assert( pOrg->length <= size ); // do not truncate
+    IMPL_RTL_STRINGDATA* pTempStr = IMPL_RTL_STRINGNAME( ImplAlloc )( size );
+    rtl_str_ImplCopy( pTempStr->buffer, pOrg->buffer, pOrg->length );
+    // right now the length is still the same as of the original
+    pTempStr->length = pOrg->length;
+    pTempStr->buffer[ pOrg->length ] = '\0';
+    *ppThis = pTempStr;
+    RTL_LOG_STRING_NEW( *ppThis );
+
+    /* must be done last, if pStr == *ppThis */
+    if ( pOrg )
+        IMPL_RTL_STRINGNAME( release )( pOrg );
+}
+
+/* ----------------------------------------------------------------------- */
+
 void SAL_CALL IMPL_RTL_STRINGNAME( newReplaceStrAt )( IMPL_RTL_STRINGDATA** ppThis,
                                                       IMPL_RTL_STRINGDATA* pStr,
                                                       sal_Int32 nIndex,
diff --git a/sal/util/sal.map b/sal/util/sal.map
index ade61cd..1eef9c6 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -652,6 +652,12 @@ LIBO_UDK_4.0 { # symbols available in >= LibO 4.0
         rtl_uString_newReplaceAllFromIndex;
 } LIBO_UDK_3.6;
 
+LIBO_UDK_4.1 { # symbols available in >= LibO 4.1
+    global:
+        rtl_string_ensureCapacity;
+        rtl_uString_ensureCapacity;
+} LIBO_UDK_4.0;
+
 PRIVATE_1.0 {
     global:
         osl_detail_ObjectRegistry_storeAddresses;
commit 5c61b8e87b6a8cda82a0857fdae4d2b2215552fb
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Dec 4 18:11:12 2012 +0100

    add doxygen tags to the internal fast string stuff
    
    Change-Id: Ie5026c116f9cc7d5b10981d53881f8a0d7986a68

diff --git a/sal/inc/rtl/strbuf.hxx b/sal/inc/rtl/strbuf.hxx
index ed627ce..77e588f 100644
--- a/sal/inc/rtl/strbuf.hxx
+++ b/sal/inc/rtl/strbuf.hxx
@@ -225,6 +225,10 @@ public:
     }
 
 #ifdef RTL_FAST_STRING
+    /**
+     @overload
+     @internal
+    */
     template< typename T1, typename T2 >
     OStringBuffer( const OStringConcat< T1, T2 >& c )
     {
@@ -854,6 +858,9 @@ private:
 };
 
 #ifdef RTL_FAST_STRING
+/**
+ @internal
+*/
 template<>
 struct ToStringHelper< OStringBuffer >
     {
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index 2acd1e8..2c73168 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -257,6 +257,10 @@ public:
     }
 
 #ifdef RTL_FAST_STRING
+    /**
+     @overload
+     @internal
+    */
     template< typename T1, typename T2 >
     OString( const OStringConcat< T1, T2 >& c )
     {
@@ -1484,6 +1488,9 @@ struct SAL_WARN_UNUSED OStringLiteral
     const char* data;
 };
 
+/**
+ @internal
+*/
 template<>
 struct ToStringHelper< OString >
     {
@@ -1493,6 +1500,9 @@ struct ToStringHelper< OString >
     static const bool allowOUStringConcat = false;
     };
 
+/**
+ @internal
+*/
 template<>
 struct ToStringHelper< OStringLiteral >
     {
@@ -1502,6 +1512,9 @@ struct ToStringHelper< OStringLiteral >
     static const bool allowOUStringConcat = false;
     };
 
+/**
+ @internal
+*/
 template< typename charT, typename traits, typename T1, typename T2 >
 inline std::basic_ostream<charT, traits> & operator <<(
     std::basic_ostream<charT, traits> & stream, const OStringConcat< T1, T2 >& concat)
diff --git a/sal/inc/rtl/ustrbuf.hxx b/sal/inc/rtl/ustrbuf.hxx
index b8f2d05..9b986b6 100644
--- a/sal/inc/rtl/ustrbuf.hxx
+++ b/sal/inc/rtl/ustrbuf.hxx
@@ -217,6 +217,10 @@ public:
 #endif
 
 #ifdef RTL_FAST_STRING
+    /**
+     @overload
+     @internal
+    */
     template< typename T1, typename T2 >
     OUStringBuffer( const OUStringConcat< T1, T2 >& c )
     {
@@ -1250,6 +1254,9 @@ private:
 };
 
 #ifdef RTL_FAST_STRING
+/**
+ @internal
+*/
 template<>
 struct ToStringHelper< OUStringBuffer >
     {
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index 656bdcf..dd7f0a4 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -325,6 +325,10 @@ public:
     }
 
 #ifdef RTL_FAST_STRING
+    /**
+     @overload
+     @internal
+    */
     template< typename T1, typename T2 >
     OUString( const OUStringConcat< T1, T2 >& c )
     {
@@ -2124,6 +2128,9 @@ struct SAL_WARN_UNUSED OUStringLiteral
     const char* data;
 };
 
+/**
+ @internal
+*/
 template<>
 struct ToStringHelper< OUString >
     {
@@ -2133,6 +2140,9 @@ struct ToStringHelper< OUString >
     static const bool allowOUStringConcat = true;
     };
 
+/**
+ @internal
+*/
 template<>
 struct ToStringHelper< OUStringLiteral >
     {
@@ -2142,6 +2152,9 @@ struct ToStringHelper< OUStringLiteral >
     static const bool allowOUStringConcat = true;
     };
 
+/**
+ @internal
+*/
 template< typename charT, typename traits, typename T1, typename T2 >
 inline std::basic_ostream<charT, traits> & operator <<(
     std::basic_ostream<charT, traits> & stream, const OUStringConcat< T1, T2 >& concat)
commit 3560c7624934eab8f8cc406828d55197b96740fe
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Dec 4 18:08:22 2012 +0100

    remove needless friend declaration
    
    Change-Id: Ib816e8126193a3477fca1334d7526743da0d4423

diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index ca9a9e3..656bdcf 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -2103,9 +2103,6 @@ public:
         rtl_uString_newFromAscii( &pNew, value );
         return OUString( pNew, (DO_NOT_ACQUIRE*)0 );
     }
-
-    template< typename T1, typename T2 >
-    friend struct OUStringConcat;
 };
 
 /* ======================================================================= */
commit 585ae2a0530d75189421c903bc12ee6c1845bd45
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Dec 4 17:45:28 2012 +0100

    ostream/OString operator<< no longer needed
    
    Change-Id: I223a9088a3465a51ea44ef28ac604f3d864f933c

diff --git a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
index 9276e99..1c12684 100644
--- a/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
+++ b/sal/qa/rtl/strings/test_ostring_stringliterals.cxx
@@ -40,18 +40,6 @@ bool rtl_string_unittest_non_const_literal_function;
 #include "rtl/string.hxx"
 #include "rtl/strbuf.hxx"
 
-namespace rtlunittest {
-
-template< typename charT, typename traits > std::basic_ostream<charT, traits> &
-operator <<(
-    std::basic_ostream<charT, traits> & stream, rtl::OString const & string)
-{
-    return stream << string.getStr();
-        // best effort; potentially loses data due to embedded null characters
-}
-
-}
-
 namespace test { namespace ostring {
 
 class StringLiterals: public CppUnit::TestFixture
commit 57369e6addb5d7a9cbbb1e17deb3ff7375b88353
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Dec 4 17:44:43 2012 +0100

    reduce a bit the rtl vs rtlunittest mess in string headers
    
    Change-Id: I27bf6d5466313a7e4a1363f481b2bd7eab142a5c

diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index cbd4b9a..2acd1e8 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -1513,18 +1513,6 @@ inline std::basic_ostream<charT, traits> & operator <<(
 typedef OString OStringLiteral;
 #endif
 
-} /* Namespace */
-
-#ifdef RTL_STRING_UNITTEST
-namespace rtl
-{
-typedef rtlunittest::OString OString;
-}
-#undef RTL_STRING_CONST_FUNCTION
-#endif
-
-namespace rtl
-{
 
 /** A helper to use OStrings with hash maps.
 
@@ -1556,7 +1544,7 @@ struct OStringHash
  */
 template< typename charT, typename traits > std::basic_ostream<charT, traits> &
 operator <<(
-    std::basic_ostream<charT, traits> & stream, rtl::OString const & string)
+    std::basic_ostream<charT, traits> & stream, OString const & string)
 {
     return stream << string.getStr();
         // best effort; potentially loses data due to embedded null characters
@@ -1564,6 +1552,14 @@ operator <<(
 
 } /* Namespace */
 
+#ifdef RTL_STRING_UNITTEST
+namespace rtl
+{
+typedef rtlunittest::OString OString;
+}
+#undef RTL_STRING_CONST_FUNCTION
+#endif
+
 #ifdef RTL_USING
 using ::rtl::OString;
 using ::rtl::OStringHash;
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index 3629511..ca9a9e3 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -2156,18 +2156,6 @@ inline std::basic_ostream<charT, traits> & operator <<(
 typedef OUString OUStringLiteral;
 #endif
 
-} /* Namespace */
-
-#ifdef RTL_STRING_UNITTEST
-namespace rtl
-{
-typedef rtlunittest::OUString OUString;
-}
-#endif
-
-namespace rtl
-{
-
 /** A helper to use OUStrings with hash maps.
 
     Instances of this class are unary function objects that can be used as
@@ -2240,17 +2228,6 @@ inline OString OUStringToOString( const OUString & rUnicode,
 
 /* ======================================================================= */
 
-} /* Namespace */
-
-#ifdef RTL_STRING_UNITTEST
-#define rtl rtlunittest
-#endif
-namespace rtl
-{
-#ifdef RTL_STRING_UNITTEST
-#undef rtl
-#endif
-
 /**
     Support for rtl::OUString in std::ostream (and thus in
     CPPUNIT_ASSERT or SAL_INFO macros, for example).
@@ -2264,13 +2241,20 @@ inline std::basic_ostream<charT, traits> & operator <<(
     std::basic_ostream<charT, traits> & stream, OUString const & string)
 {
     return stream <<
-        rtl::OUStringToOString(string, RTL_TEXTENCODING_UTF8).getStr();
+        OUStringToOString(string, RTL_TEXTENCODING_UTF8).getStr();
         // best effort; potentially loses data due to conversion failures
         // (stray surrogate halves) and embedded null characters
 }
 
 } // namespace
 
+#ifdef RTL_STRING_UNITTEST
+namespace rtl
+{
+typedef rtlunittest::OUString OUString;
+}
+#endif
+
 // RTL_USING is defined by gbuild for all modules except those with stable public API
 // (as listed in ure/source/README). It allows to use classes like OUString without
 // having to explicitly refer to the rtl namespace, which is kind of superfluous
commit 4566d3c24809b51d9209d1d7183feaffe0a393c0
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Dec 4 17:29:17 2012 +0100

    committed by mistake
    
    Change-Id: I40a4aa2239736a081a94b04c2f510866be5ac54c

diff --git a/sal/qa/rtl/strings/test_oustring_concat.cxx b/sal/qa/rtl/strings/test_oustring_concat.cxx
index 4f650dc..7eefb6f 100644
--- a/sal/qa/rtl/strings/test_oustring_concat.cxx
+++ b/sal/qa/rtl/strings/test_oustring_concat.cxx
@@ -60,7 +60,6 @@ void test::oustring::StringConcat::check()
     CPPUNIT_ASSERT_EQUAL( OUString( "fooxyz" ), OUString( OUString( "foo" ) + d1 ));
     TYPES_ASSERT_EQUAL(( typeid( OUStringConcat< OUString, const char[ 4 ] > )), typeid( OUString( "foo" ) + d1 ));
 }
-#undef typeid
 
 }} // namespace
 


More information about the Libreoffice-commits mailing list