[PATCH] String->OUString more unotools

Norbert Thiebaud (via Code Review) gerrit at gerrit.libreoffice.org
Thu Jun 13 06:19:13 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/4248

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/48/4248/1

String->OUString more unotools

Change-Id: I50f61d62b6b1dc348a0253e94b7e334baaec2bb0
---
M basic/source/classes/errobject.cxx
M basic/source/comp/buffer.cxx
M include/unotools/textsearch.hxx
M include/unotools/transliterationwrapper.hxx
M include/unotools/ucblockbytes.hxx
M unotools/source/i18n/textsearch.cxx
M unotools/source/i18n/transliterationwrapper.cxx
M unotools/source/ucbhelper/ucblockbytes.cxx
8 files changed, 90 insertions(+), 55 deletions(-)



diff --git a/basic/source/classes/errobject.cxx b/basic/source/classes/errobject.cxx
index 7cfce56..c856f16 100644
--- a/basic/source/classes/errobject.cxx
+++ b/basic/source/classes/errobject.cxx
@@ -81,7 +81,7 @@
 void SAL_CALL
 ErrObject::setNumber( ::sal_Int32 _number ) throw (uno::RuntimeException)
 {
-    GetSbData()->pInst->setErrorVB( _number, String() );
+    GetSbData()->pInst->setErrorVB( _number, OUString() );
     OUString _description = GetSbData()->pInst->GetErrorMsg();
     setData( uno::makeAny( _number ), uno::Any(), uno::makeAny( _description ), uno::Any(), uno::Any() );
 }
diff --git a/basic/source/comp/buffer.cxx b/basic/source/comp/buffer.cxx
index b08d352..dac618d 100644
--- a/basic/source/comp/buffer.cxx
+++ b/basic/source/comp/buffer.cxx
@@ -17,7 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
+#include <rtl/ustring.hxx>
+#include <osl/thread.h> // osl_getThreadTextEncoding
 #include "buffer.hxx"
 #include "sbcomp.hxx"
 
diff --git a/include/unotools/textsearch.hxx b/include/unotools/textsearch.hxx
index f26d150..1a07e8b 100644
--- a/include/unotools/textsearch.hxx
+++ b/include/unotools/textsearch.hxx
@@ -162,13 +162,17 @@
     int SearchFrwrd( const String &rStr,
                     xub_StrLen* pStart, xub_StrLen* pEnde,
                     ::com::sun::star::util::SearchResult* pSrchResult = 0 );
-    sal_Bool SearchForward( const OUString &rStr,
-                    sal_Int32* pStart, sal_Int32* pEnd,
-                    ::com::sun::star::util::SearchResult* pRes = 0 );
+    bool SearchForward( const OUString &rStr,
+                        sal_Int32* pStart, sal_Int32* pEnd,
+                        ::com::sun::star::util::SearchResult* pRes = 0 );
     int SearchBkwrd( const String &rStr,
                     xub_StrLen* pStart, xub_StrLen* pEnde,
                     ::com::sun::star::util::SearchResult* pSrchResult = 0 );
 
+    bool SearchBackward( const OUString &rStr,
+                         sal_Int32* pStart, sal_Int32* pEnde,
+                         ::com::sun::star::util::SearchResult* pSrchResult = 0 );
+
     void SetLocale( const ::com::sun::star::util::SearchOptions& rOpt,
                     const ::com::sun::star::lang::Locale& rLocale );
 
diff --git a/include/unotools/transliterationwrapper.hxx b/include/unotools/transliterationwrapper.hxx
index 6d64d40..4af650d 100644
--- a/include/unotools/transliterationwrapper.hxx
+++ b/include/unotools/transliterationwrapper.hxx
@@ -20,7 +20,7 @@
 
 #ifndef _UNOTOOLS_TRANSLITERATIONWRAPPER_HXX
 #define _UNOTOOLS_TRANSLITERATIONWRAPPER_HXX
-#include <tools/string.hxx>
+#include <rtl/ustring.hxx>
 #include <tools/solar.h>
 #include <i18nlangtag/languagetag.hxx>
 #include <com/sun/star/i18n/XExtendedTransliteration.hpp>
@@ -80,20 +80,20 @@
         those may load a different module and overwrite this setting. Only the
         transliterate() method that takes no LanguageType parameter may be used
         for a specific module loaded with this method.  */
-    void loadModuleByImplName( const String& rModuleName, sal_uInt16 nLang );
+    void loadModuleByImplName( const OUString& rModuleName, sal_uInt16 nLang );
 
     /** This transliteration method corresponds with the loadModuleByImplName()
         method. It relies on a module being loaded and does not try load one.
         If for any reason the string can't be transliterated the original
         string is returned.  */
-    String transliterate( const String& rStr,
-                        xub_StrLen nStart, xub_StrLen nLen,
-                        ::com::sun::star::uno::Sequence <sal_Int32>* pOffset ) const;
+    OUString transliterate( const OUString& rStr,
+                            sal_Int32 nStart, sal_Int32 nLen,
+                            ::com::sun::star::uno::Sequence <sal_Int32>* pOffset ) const;
 
     // Wrapper implementations of class Transliteration
-    String transliterate( const String& rStr, sal_uInt16 nLanguage,
-                        xub_StrLen nStart, xub_StrLen nLen,
-                        ::com::sun::star::uno::Sequence <sal_Int32>* pOffset );
+    OUString transliterate( const OUString& rStr, sal_uInt16 nLanguage,
+                            sal_Int32 nStart, sal_Int32 nLen,
+                            ::com::sun::star::uno::Sequence <sal_Int32>* pOffset );
 
     /** If two strings are equal per this transliteration.
         Returns the number of matched code points in any case, even if strings
@@ -104,10 +104,10 @@
         returns false and nMatch:=2 and nMatch2:=2
      */
     sal_Bool equals(
-        const String& rStr1, sal_Int32 nPos1, sal_Int32 nCount1, sal_Int32& nMatch1,
-        const String& rStr2, sal_Int32 nPos2, sal_Int32 nCount2, sal_Int32& nMatch2 ) const;
+        const OUString& rStr1, sal_Int32 nPos1, sal_Int32 nCount1, sal_Int32& nMatch1,
+        const OUString& rStr2, sal_Int32 nPos2, sal_Int32 nCount2, sal_Int32& nMatch2 ) const;
 
-    sal_Int32 compareString( const String& rStr1, const String& rStr2 ) const;
+    sal_Int32 compareString( const OUString& rStr1, const OUString& rStr2 ) const;
 
 
     // helpers
@@ -116,11 +116,11 @@
         one string is matching the start of the other. Use this method instead
         of compareString()==0 because it is much faster.
      */
-    sal_Bool isEqual( const String& rStr1, const String& rStr2 ) const;
+    sal_Bool isEqual( const OUString& rStr1, const OUString& rStr2 ) const;
 
     /** If string rStr1 matches the start of string rStr2, i.e. "a" in "aaa"
      */
-    sal_Bool isMatch( const String& rStr1, const String& rStr2 ) const;
+    sal_Bool isMatch( const OUString& rStr1, const OUString& rStr2 ) const;
 
 };
 
diff --git a/include/unotools/ucblockbytes.hxx b/include/unotools/ucblockbytes.hxx
index cf5d98b..cbb635e 100644
--- a/include/unotools/ucblockbytes.hxx
+++ b/include/unotools/ucblockbytes.hxx
@@ -94,8 +94,8 @@
     osl::Condition          m_aTerminated;
     osl::Mutex              m_aMutex;
 
-    String                  m_aContentType;
-    String                  m_aRealURL;
+    OUString                m_aContentType;
+    OUString                m_aRealURL;
     DateTime                m_aExpireDate;
 
     ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >  m_xInputStream;
@@ -144,8 +144,8 @@
                             { return m_nError; }
 
     // the following properties are available when and after the first DataAvailable callback has been executed
-    String                  GetContentType() const;
-    String                  GetRealURL() const;
+    OUString                GetContentType() const;
+    OUString                GetRealURL() const;
     DateTime                GetExpireDate() const;
 
     // calling this method delegates the responsibility to call closeinput to the caller!
@@ -183,8 +183,8 @@
     void                    setDontClose_Impl()
                             { m_bDontClose = sal_True; }
 
-    void                    SetContentType_Impl( const String& rType ) { m_aContentType = rType; }
-    void                    SetRealURL_Impl( const String& rURL )  { m_aRealURL = rURL; }
+    void                    SetContentType_Impl( const OUString& rType ) { m_aContentType = rType; }
+    void                    SetRealURL_Impl( const OUString& rURL )  { m_aRealURL = rURL; }
     void                    SetExpireDate_Impl( const DateTime& rDateTime )  { m_aExpireDate = rDateTime; }
     void                    SetStreamValid_Impl();
 };
diff --git a/unotools/source/i18n/textsearch.cxx b/unotools/source/i18n/textsearch.cxx
index dfb871e..9d8470a 100644
--- a/unotools/source/i18n/textsearch.cxx
+++ b/unotools/source/i18n/textsearch.cxx
@@ -237,11 +237,11 @@
     return nRet;
 }
 
-sal_Bool TextSearch::SearchForward( const OUString &rStr,
-                    sal_Int32* pStart, sal_Int32* pEnd,
-                    ::com::sun::star::util::SearchResult* pRes)
+bool TextSearch::SearchForward( const OUString &rStr,
+                                sal_Int32* pStart, sal_Int32* pEnd,
+                                ::com::sun::star::util::SearchResult* pRes)
 {
-    sal_Bool nRet = sal_False;
+    bool nRet = false;
     try
     {
         if( xTextSearch.is() )
@@ -250,7 +250,7 @@
                                                     rStr, *pStart, *pEnd ));
             if( aRet.subRegExpressions > 0 )
             {
-                nRet = sal_True;
+                nRet = true;
                 // the XTextsearch returns in startOffset the higher position
                 // and the endposition is always exclusive.
                 // The caller of this function will have in startPos the
@@ -301,6 +301,36 @@
     return nRet;
 }
 
+bool TextSearch::SearchBackward( const OUString & rStr, sal_Int32* pStart,
+                                 sal_Int32* pEnde, SearchResult* pRes )
+{
+    bool nRet = false;
+    try
+    {
+        if( xTextSearch.is() )
+        {
+            SearchResult aRet( xTextSearch->searchBackward( rStr, *pStart, *pEnde ));
+            if( aRet.subRegExpressions )
+            {
+                nRet = true;
+                // the XTextsearch returns in startOffset the higher position
+                // and the endposition is always exclusive.
+                // The caller of this function will have in startPos the
+                // lower pos. and end
+                *pEnde = aRet.startOffset[ 0 ];
+                *pStart = aRet.endOffset[ 0 ];
+                if( pRes )
+                    *pRes = aRet;
+            }
+        }
+    }
+    catch ( Exception& )
+    {
+        SAL_WARN( "unotools.i18n", "SearchBackward: Exception caught!" );
+    }
+    return nRet;
+}
+
 void TextSearch::ReplaceBackReferences( String& rReplaceStr, const String &rStr, const SearchResult& rResult )
 {
     if( rResult.subRegExpressions > 0 )
diff --git a/unotools/source/i18n/transliterationwrapper.cxx b/unotools/source/i18n/transliterationwrapper.cxx
index 703c37e..3b7bf38 100644
--- a/unotools/source/i18n/transliterationwrapper.cxx
+++ b/unotools/source/i18n/transliterationwrapper.cxx
@@ -44,12 +44,12 @@
 }
 
 
-String TransliterationWrapper::transliterate(
-                                const String& rStr, sal_uInt16 nLang,
-                                xub_StrLen nStart, xub_StrLen nLen,
+OUString TransliterationWrapper::transliterate(
+                                const OUString& rStr, sal_uInt16 nLang,
+                                sal_Int32 nStart, sal_Int32 nLen,
                                 Sequence <sal_Int32>* pOffset )
 {
-    String sRet;
+    OUString sRet;
     if( xTrans.is() )
     {
         try
@@ -70,12 +70,12 @@
 }
 
 
-String TransliterationWrapper::transliterate(
-                                const String& rStr,
-                                xub_StrLen nStart, xub_StrLen nLen,
-                                Sequence <sal_Int32>* pOffset ) const
+OUString TransliterationWrapper::transliterate(const OUString& rStr,
+                                               sal_Int32 nStart,
+                                               sal_Int32 nLen,
+                                               Sequence <sal_Int32>* pOffset ) const
 {
-    String sRet( rStr );
+    OUString sRet( rStr );
     if( xTrans.is() )
     {
         try
@@ -166,7 +166,7 @@
 
 
 void TransliterationWrapper::loadModuleByImplName(
-        const String& rModuleName, sal_uInt16 nLang )
+        const OUString& rModuleName, sal_uInt16 nLang )
 {
     try
     {
@@ -188,8 +188,8 @@
 
 
 sal_Bool TransliterationWrapper::equals(
-    const String& rStr1, sal_Int32 nPos1, sal_Int32 nCount1, sal_Int32& nMatch1,
-    const String& rStr2, sal_Int32 nPos2, sal_Int32 nCount2, sal_Int32& nMatch2 ) const
+    const OUString& rStr1, sal_Int32 nPos1, sal_Int32 nCount1, sal_Int32& nMatch1,
+    const OUString& rStr2, sal_Int32 nPos2, sal_Int32 nCount2, sal_Int32& nMatch2 ) const
 {
     try
     {
@@ -205,7 +205,7 @@
     return sal_False;
 }
 
-sal_Int32 TransliterationWrapper::compareString( const String& rStr1, const String& rStr2 ) const
+sal_Int32 TransliterationWrapper::compareString( const OUString& rStr1, const OUString& rStr2 ) const
 {
     try
     {
@@ -224,23 +224,23 @@
 
 // --- helpers --------------------------------------------------------
 
-sal_Bool TransliterationWrapper::isEqual( const String& rStr1, const String& rStr2 ) const
+sal_Bool TransliterationWrapper::isEqual( const OUString& rStr1, const OUString& rStr2 ) const
 {
     sal_Int32 nMatch1, nMatch2;
     sal_Bool bMatch = equals(
-        rStr1, 0, rStr1.Len(), nMatch1,
-        rStr2, 0, rStr2.Len(), nMatch2 );
+        rStr1, 0, rStr1.getLength(), nMatch1,
+        rStr2, 0, rStr2.getLength(), nMatch2 );
     return bMatch;
 }
 
 
-sal_Bool TransliterationWrapper::isMatch( const String& rStr1, const String& rStr2 ) const
+sal_Bool TransliterationWrapper::isMatch( const OUString& rStr1, const OUString& rStr2 ) const
 {
     sal_Int32 nMatch1, nMatch2;
     equals(
-        rStr1, 0, rStr1.Len(), nMatch1,
-        rStr2, 0, rStr2.Len(), nMatch2 );
-    return (nMatch1 <= nMatch2) && (nMatch1 == rStr1.Len());
+        rStr1, 0, rStr1.getLength(), nMatch1,
+        rStr2, 0, rStr2.getLength(), nMatch2 );
+    return (nMatch1 <= nMatch2) && (nMatch1 == rStr1.getLength());
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx
index d60f249..b1541dd 100644
--- a/unotools/source/ucbhelper/ucblockbytes.cxx
+++ b/unotools/source/ucbhelper/ucblockbytes.cxx
@@ -194,10 +194,10 @@
                 sal_Int32 k, m = aHead.getLength();
                 for (k = 0; k < m; k++)
                 {
-                    String aName( aHead[k].Name );
-                    String aValue( aHead[k].Value );
+                    OUString aName( aHead[k].Name );
+                    OUString aValue( aHead[k].Value );
 
-                    if (aName.CompareIgnoreCaseToAscii("Expires") == COMPARE_EQUAL)
+                    if (aName.compareToIgnoreAsciiCase("Expires") == 0 )
                     {
                         DateTime aExpires (0, 0);
                         if (INetRFC822Message::ParseDateField (aValue, aExpires))
@@ -917,8 +917,8 @@
         return _UCBOpenContentSync(
             xLockBytes,xContent,rArg,xSink,xInteract,xProgress,xHandler);
 
-    if ( (aScheme.compareToAscii( "http" ) != COMPARE_EQUAL) ||
-         (aScheme.compareToAscii( "https" ) != COMPARE_EQUAL) )
+    if ( (aScheme.compareToAscii( "http" ) != 0 ) ||
+         (aScheme.compareToAscii( "https" ) != 0 ) )
         xLockBytes->SetStreamValid_Impl();
 
     Reference< XPropertiesChangeListener > xListener;
@@ -1154,7 +1154,7 @@
 
     // http protocol must be handled in a special way: during the opening process the input stream may change
     // only the last inputstream after notifying the document headers is valid
-    if ( aScheme.compareToAscii("http") != COMPARE_EQUAL )
+    if ( aScheme.compareToAscii("http") != 0 )
         xLockBytes->SetStreamValid_Impl();
 
     Reference< XPropertiesChangeListener > xListener = new UcbPropertiesChangeListener_Impl( xLockBytes );

-- 
To view, visit https://gerrit.libreoffice.org/4248
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I50f61d62b6b1dc348a0253e94b7e334baaec2bb0
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Norbert Thiebaud <nthiebaud at gmail.com>



More information about the LibreOffice mailing list