[PATCH] Replace String with OUString (unotools)

Christina Roßmanith (via_Code_Review) gerrit at gerrit.libreoffice.org
Wed Mar 20 02:30:26 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2864

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/64/2864/1

Replace String with OUString (unotools)

Change-Id: I9a0677cb36805d0a27514824c937901f73fee1c8
---
M cui/source/dialogs/hldocntp.cxx
M cui/source/dialogs/hldoctp.cxx
M cui/source/dialogs/hltpbase.cxx
M cui/source/dialogs/multipat.cxx
M fpicker/source/office/iodlg.cxx
M sd/source/filter/ppt/pptin.cxx
M sfx2/source/appl/linkmgr2.cxx
M sfx2/source/doc/printhelper.cxx
M sfx2/source/inet/inettbc.cxx
M svtools/source/control/inettbc.cxx
M svx/source/dialog/docrecovery.cxx
M unotools/inc/unotools/localfilehelper.hxx
M unotools/source/ucbhelper/localfilehelper.cxx
M uui/source/fltdlg.cxx
14 files changed, 53 insertions(+), 51 deletions(-)



diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx
index 6e1a971..2032577 100644
--- a/cui/source/dialogs/hldocntp.cxx
+++ b/cui/source/dialogs/hldocntp.cxx
@@ -402,13 +402,13 @@
     uno::Reference < XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
     uno::Reference < XFolderPicker2 >  xFolderPicker = FolderPicker::create(xContext);
 
-    String              aStrURL;
-    String              aTempStrURL( maCbbPath.GetText() );
+    OUString            aStrURL;
+    OUString            aTempStrURL( maCbbPath.GetText() );
     utl::LocalFileHelper::ConvertSystemPathToURL( aTempStrURL, maCbbPath.GetBaseURL(), aStrURL );
 
     String              aStrPath = aStrURL;
-    sal_Bool                bZeroPath = ( aStrPath.Len() == 0 );
-    sal_Bool                bHandleFileName = bZeroPath;    // when path has length of 0, then the rest should always be handled
+    sal_Bool            bZeroPath = ( aStrPath.Len() == 0 );
+    sal_Bool            bHandleFileName = bZeroPath;    // when path has length of 0, then the rest should always be handled
                                                         //  as file name, otherwise we do not yet know
 
     if( bZeroPath )
@@ -427,13 +427,13 @@
         INetURLObject   aURL( aStrURL, INET_PROT_FILE );
         String          aStrName;
         if( bHandleFileName )
-            aStrName = bZeroPath? aTempStrURL : String(aURL.getName());
+            aStrName = bZeroPath? aTempStrURL : OUString(aURL.getName());
 
         maCbbPath.SetBaseURL( xFolderPicker->getDirectory() );
-        String          aStrTmp( xFolderPicker->getDirectory() );
+        OUString          aStrTmp( xFolderPicker->getDirectory() );
 
-        if( aStrTmp.GetChar( aStrTmp.Len() - 1 ) != sSlash[0] )
-            aStrTmp.AppendAscii( sSlash );
+        if( aStrTmp[ aStrTmp.getLength() - 1 ] != sSlash[0] )
+            aStrTmp += OUString( sSlash );
 
         // append old file name
         if( bHandleFileName )
diff --git a/cui/source/dialogs/hldoctp.cxx b/cui/source/dialogs/hldoctp.cxx
index 21fcce5..a7db3c3 100644
--- a/cui/source/dialogs/hldoctp.cxx
+++ b/cui/source/dialogs/hldoctp.cxx
@@ -120,7 +120,7 @@
 String SvxHyperlinkDocTp::GetCurrentURL ()
 {
     // get data from dialog-controls
-    String aStrURL;
+    OUString aStrURL;
     String aStrPath ( maCbbPath.GetText() );
     const String aBaseURL ( maCbbPath.GetBaseURL() );
     String aStrMark( maEdTarget.GetText() );
@@ -140,7 +140,7 @@
 
     if( aStrMark != aEmptyStr )
     {
-        aStrURL.AppendAscii( sHash );
+        aStrURL += OUString( sHash );
         aStrURL += aStrMark;
     }
 
@@ -213,7 +213,7 @@
     if ( ERRCODE_NONE == nError )
     {
         String aURL( aDlg.GetPath() );
-        String aPath;
+        OUString aPath;
 
         utl::LocalFileHelper::ConvertURLToSystemPath( aURL, aPath );
 
diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index dfb0037..9df36a8 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -515,7 +515,7 @@
 
 String SvxHyperlinkTabPageBase::CreateUiNameFromURL( const String& aStrURL )
 {
-    String          aStrUiURL;
+    OUString          aStrUiURL;
     INetURLObject   aURLObj( aStrURL );
 
     switch(aURLObj.GetProtocol())
@@ -536,7 +536,7 @@
                 aStrUiURL = aURLObj.GetMainURL(INetURLObject::DECODE_UNAMBIGUOUS);
             }
     }
-    if(!aStrUiURL.Len())
+    if(aStrUiURL.isEmpty())
         return aStrURL;
     return aStrUiURL;
 }
diff --git a/cui/source/dialogs/multipat.cxx b/cui/source/dialogs/multipat.cxx
index 1b2f139..3dad748 100644
--- a/cui/source/dialogs/multipat.cxx
+++ b/cui/source/dialogs/multipat.cxx
@@ -88,7 +88,7 @@
         INetURLObject aPath( xFolderPicker->getDirectory() );
         aPath.removeFinalSlash();
         String aURL = aPath.GetMainURL( INetURLObject::NO_DECODE );
-        String sInsPath;
+        OUString sInsPath;
         ::utl::LocalFileHelper::ConvertURLToSystemPath( aURL, sInsPath );
 
         if ( pImpl->bIsRadioButtonMode )
@@ -278,14 +278,14 @@
     for ( sal_uInt16 i = 0; i < nCount; ++i )
     {
         String sPath = rPath.GetToken( i, cDelim );
-        String sSystemPath;
+        OUString sSystemPath;
         sal_Bool bIsSystemPath =
             ::utl::LocalFileHelper::ConvertURLToSystemPath( sPath, sSystemPath );
 
         if ( pImpl->bIsRadioButtonMode )
         {
             rtl::OUString sEntry( '\t' );
-            sEntry += (bIsSystemPath ? sSystemPath : sPath);
+            sEntry += (bIsSystemPath ? sSystemPath : OUString(sPath));
             SvTreeListEntry* pEntry = aRadioLB.InsertEntry( sEntry );
             String* pURL = new String( sPath );
             pEntry->SetUserData( pURL );
diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx
index 592005c..51b05ec 100644
--- a/fpicker/source/office/iodlg.cxx
+++ b/fpicker/source/office/iodlg.cxx
@@ -1202,7 +1202,7 @@
             }
             else
             {
-                String aCurPath;
+                OUString aCurPath;
                 if ( ::utl::LocalFileHelper::ConvertURLToSystemPath( aFileName, aCurPath ) )
                 {
                     // if content does not exist: at least its path must exist
@@ -1545,13 +1545,13 @@
 
     //=========================================================================
     {
-        String sText;
+        OUString sText;
         DBG_ASSERT( INET_PROT_NOT_VALID != aObj.GetProtocol(), "SvtFileDialog::UpdateControls: Invalid URL!" );
 
         if ( aObj.getSegmentCount() )
         {
             ::utl::LocalFileHelper::ConvertURLToSystemPath( rURL, sText );
-            if ( sText.Len() )
+            if ( !sText.isEmpty() )
             {
                 // no Fsys path for server file system ( only UCB has mountpoints! )
                 if ( INET_PROT_FILE != aObj.GetProtocol() )
@@ -1559,7 +1559,7 @@
                         INetURLObject::GetScheme( aObj.GetProtocol() ).getLength() ) );
             }
 
-            if ( !sText.Len() && aObj.getSegmentCount() )
+            if ( sText.isEmpty() && aObj.getSegmentCount() )
                 sText = rURL;
         }
 
@@ -1577,7 +1577,7 @@
                 sText = sURL;
         }
 
-        if ( !sText.Len() && rURL.Len() )
+        if ( sText.isEmpty() && rURL.Len() )
             // happens, for instance, for URLs which the INetURLObject does not know to belong to a hierarchical scheme
             sText = rURL;
         _pImp->_pEdCurrentPath->SetText( sText );
@@ -1973,13 +1973,13 @@
     try
     {
         // create make a human-readable string from the URL
-        String sDisplayPath( _rURL );
+        OUString sDisplayPath( _rURL );
         ::utl::LocalFileHelper::ConvertURLToSystemPath( _rURL, sDisplayPath );
 
         // build an own exception which tells "access denied"
         InteractiveAugmentedIOException aException;
         aException.Arguments.realloc( 2 );
-        aException.Arguments[ 0 ] <<= OUString( sDisplayPath );
+        aException.Arguments[ 0 ] <<= sDisplayPath;
         aException.Arguments[ 1 ] <<= PropertyValue(
             OUString( "Uri" ),
             -1, aException.Arguments[ 0 ], PropertyState_DIRECT_VALUE
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 5ffeb01..5764f3e 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -2092,11 +2092,11 @@
                             if ( pDocShell )
                             {
                                 String aBaseURL = pDocShell->GetMedium()->GetBaseURL();
-                                String aBookmarkURL( pInfo->GetBookmark() );
+                                OUString aBookmarkURL( pInfo->GetBookmark() );
                                 INetURLObject aURL( pPtr->aTarget );
                                 if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
                                     utl::LocalFileHelper::ConvertSystemPathToURL( pPtr->aTarget, aBaseURL, aBookmarkURL );
-                                if( !aBookmarkURL.Len() )
+                                if( aBookmarkURL.isEmpty() )
                                     aBookmarkURL = URIHelper::SmartRel2Abs( INetURLObject(aBaseURL), pPtr->aTarget, URIHelper::GetMaybeFileHdl(), true );
                                 pInfo->SetBookmark( aBookmarkURL );
                                 pInfo->meClickAction = ::com::sun::star::presentation::ClickAction_PROGRAM;
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index 32d3919..b1ccfaf 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -585,15 +585,15 @@
 
 
 // ----------------------------------------------------------------------
-String lcl_DDE_RelToAbs( const String& rTopic, const String& rBaseURL )
+String lcl_DDE_RelToAbs( const OUString& rTopic, const OUString& rBaseURL )
 {
-    String sRet;
+    OUString sRet;
     INetURLObject aURL( rTopic );
     if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
         utl::LocalFileHelper::ConvertSystemPathToURL( rTopic, rBaseURL, sRet );
-    if( !sRet.Len() )
+    if( sRet.isEmpty() )
         sRet = URIHelper::SmartRel2Abs( INetURLObject(rBaseURL), rTopic, URIHelper::GetMaybeFileHdl(), true );
-    return sRet;
+    return String(sRet);
 }
 
 sal_Bool SvxInternalLink::Connect( sfx2::SvBaseLink* pLink )
diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx
index 8cc782e..8b78c9b 100644
--- a/sfx2/source/doc/printhelper.cxx
+++ b/sfx2/source/doc/printhelper.cxx
@@ -627,8 +627,8 @@
                 throw ::com::sun::star::lang::IllegalArgumentException();
             }
 
-            String        sPath        ;
-            String        sURL  (sTemp);
+            OUString      sPath        ;
+            OUString      sURL  (sTemp);
             INetURLObject aCheck(sURL );
             if (aCheck.GetProtocol()==INET_PROT_NOT_VALID)
             {
@@ -665,7 +665,7 @@
                 // and append the local filename
                 aCheckedArgs.realloc( aCheckedArgs.getLength()+1 );
                 aCheckedArgs[nProps].Name = rtl::OUString("LocalFileName");
-                aCheckedArgs[nProps++].Value <<= ::rtl::OUString( sPath );
+                aCheckedArgs[nProps++].Value <<= sPath;
             }
             else
             {
@@ -682,7 +682,7 @@
                 pUCBPrintTempFile->EnableKillingFile();
 
                 //FIXME: does it work?
-                aCheckedArgs[nProps].Name = rtl::OUString("LocalFileName");
+                aCheckedArgs[nProps].Name = "LocalFileName";
                 aCheckedArgs[nProps++].Value <<= ::rtl::OUString( pUCBPrintTempFile->GetFileName() );
                 sUcbUrl = sURL;
             }
diff --git a/sfx2/source/inet/inettbc.cxx b/sfx2/source/inet/inettbc.cxx
index 1a70998f..14737d7 100644
--- a/sfx2/source/inet/inettbc.cxx
+++ b/sfx2/source/inet/inettbc.cxx
@@ -240,8 +240,8 @@
                         continue;
 
                     INetURLObject aURL    ( sURL );
-                    String        sMainURL( aURL.GetMainURL( INetURLObject::DECODE_WITH_CHARSET ) );
-                    String        sFile;
+                    OUString      sMainURL( aURL.GetMainURL( INetURLObject::DECODE_WITH_CHARSET ) );
+                    OUString      sFile;
 
                     if (::utl::LocalFileHelper::ConvertURLToSystemPath(sMainURL,sFile))
                         pURLBox->InsertEntry(sFile);
diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx
index 983e4ca..603e5ee 100644
--- a/svtools/source/control/inettbc.cxx
+++ b/svtools/source/control/inettbc.cxx
@@ -555,7 +555,9 @@
     }
     else
     {
-        ::utl::LocalFileHelper::ConvertSystemPathToURL( aText, aWorkDir, aMatch );
+        OUString aTmpMatch;
+        ::utl::LocalFileHelper::ConvertSystemPathToURL( OUString(aText), OUString(aWorkDir), aTmpMatch );
+        aMatch = aTmpMatch;
     }
 
     return aMatch;
@@ -988,7 +990,7 @@
                         }
                         if ( bFound )
                         {
-                            String aFile;
+                            OUString aFile;
                             if (::utl::LocalFileHelper::ConvertURLToSystemPath(aURL,aFile))
                                 InsertEntry(aFile);
                             else
diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx
index 103599d..ae21036 100644
--- a/svx/source/dialog/docrecovery.cxx
+++ b/svx/source/dialog/docrecovery.cxx
@@ -1398,7 +1398,7 @@
 
     m_sSavePath = SvtPathOptions().GetWorkPath();
     INetURLObject aObj( m_sSavePath );
-    String sPath;
+    OUString sPath;
     ::utl::LocalFileHelper::ConvertURLToSystemPath( aObj.GetMainURL( INetURLObject::NO_DECODE ), sPath );
     m_aSaveDirED.SetText( sPath );
 
@@ -1498,7 +1498,7 @@
     if (nRet == css::ui::dialogs::ExecutableDialogResults::OK)
     {
         m_sSavePath = xFolderPicker->getDirectory();
-        String sPath;
+        OUString sPath;
         ::utl::LocalFileHelper::ConvertURLToSystemPath( m_sSavePath, sPath );
         m_aSaveDirED.SetText( sPath );
     }
diff --git a/unotools/inc/unotools/localfilehelper.hxx b/unotools/inc/unotools/localfilehelper.hxx
index 99831f7..963b6ca 100644
--- a/unotools/inc/unotools/localfilehelper.hxx
+++ b/unotools/inc/unotools/localfilehelper.hxx
@@ -36,7 +36,7 @@
         Returning sal_True and an empty URL means that the URL doesn't point to a local file.
         */
         static bool ConvertPhysicalNameToURL(const rtl::OUString& rName, rtl::OUString& rReturn);
-        static sal_Bool ConvertSystemPathToURL( const String& rName, const String& rBaseURL, String& rReturn );
+        static sal_Bool ConvertSystemPathToURL( const OUString& rName, const OUString& rBaseURL, OUString& rReturn );
 
         /**
         Converts a "UCB compatible" URL into a "physical" file name.
@@ -45,7 +45,7 @@
         file system is present ( watch: this doesn't mean that this file really exists! )
         */
         static bool ConvertURLToPhysicalName( const rtl::OUString& rName, rtl::OUString& rReturn );
-        static sal_Bool ConvertURLToSystemPath( const String& rName, String& rReturn );
+        static sal_Bool ConvertURLToSystemPath( const OUString& rName, OUString& rReturn );
 
         static sal_Bool IsLocalFile(const rtl::OUString& rName);
         static sal_Bool IsFileContent(const rtl::OUString& rName);
diff --git a/unotools/source/ucbhelper/localfilehelper.cxx b/unotools/source/ucbhelper/localfilehelper.cxx
index ef0acbe..e02da35 100644
--- a/unotools/source/ucbhelper/localfilehelper.cxx
+++ b/unotools/source/ucbhelper/localfilehelper.cxx
@@ -37,9 +37,9 @@
 namespace utl
 {
 
-sal_Bool LocalFileHelper::ConvertSystemPathToURL( const String& rName, const String& rBaseURL, String& rReturn )
+sal_Bool LocalFileHelper::ConvertSystemPathToURL( const OUString& rName, const OUString& rBaseURL, OUString& rReturn )
 {
-    rReturn = ::rtl::OUString();
+    rReturn = "";
 
     Reference< XUniversalContentBroker > pBroker(
         UniversalContentBroker::create(
@@ -53,12 +53,12 @@
         return sal_False;
     }
 
-    return ( rReturn.Len() != 0 );
+    return !rReturn.isEmpty();
 }
 
-sal_Bool LocalFileHelper::ConvertURLToSystemPath( const String& rName, String& rReturn )
+sal_Bool LocalFileHelper::ConvertURLToSystemPath( const OUString& rName, OUString& rReturn )
 {
-    rReturn = ::rtl::OUString();
+    rReturn = "";
     Reference< XUniversalContentBroker > pBroker(
         UniversalContentBroker::create(
             comphelper::getProcessComponentContext() ) );
@@ -70,7 +70,7 @@
     {
     }
 
-    return ( rReturn.Len() != 0 );
+    return !rReturn.isEmpty();
 }
 
 bool LocalFileHelper::ConvertPhysicalNameToURL(const rtl::OUString& rName, rtl::OUString& rReturn)
@@ -93,7 +93,7 @@
 
 bool LocalFileHelper::ConvertURLToPhysicalName(const rtl::OUString& rName, rtl::OUString& rReturn)
 {
-    rReturn = ::rtl::OUString();
+    rReturn = "";
     Reference< XUniversalContentBroker > pBroker(
         UniversalContentBroker::create(
             comphelper::getProcessComponentContext() ) );
@@ -119,7 +119,7 @@
 
 sal_Bool LocalFileHelper::IsFileContent(const rtl::OUString& rName)
 {
-    String aTmp;
+    OUString aTmp;
     return ConvertURLToSystemPath(rName, aTmp);
 }
 
@@ -136,7 +136,7 @@
         Reference< ::com::sun::star::sdbc::XResultSet > xResultSet;
         ::com::sun::star::uno::Sequence< ::rtl::OUString > aProps(1);
         ::rtl::OUString* pProps = aProps.getArray();
-        pProps[0] = ::rtl::OUString("Url");
+        pProps[0] = "Url";
 
         try
         {
diff --git a/uui/source/fltdlg.cxx b/uui/source/fltdlg.cxx
index 3571b2e..adab1d9 100644
--- a/uui/source/fltdlg.cxx
+++ b/uui/source/fltdlg.cxx
@@ -206,7 +206,7 @@
 *//*-*************************************************************************************************************/
 String FilterDialog::impl_buildUIFileName( const String& sName )
 {
-    String sShortName( sName );
+    OUString sShortName( sName );
 
     if( ::utl::LocalFileHelper::ConvertURLToSystemPath( sName, sShortName ) == sal_True )
     {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9a0677cb36805d0a27514824c937901f73fee1c8
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Christina Roßmanith <ChrRossmanith at web.de>



More information about the LibreOffice mailing list