summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-01-09 21:05:46 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-01-10 10:09:28 +0000
commit3c62fbcdd78e472d3dde604eff33be54cb3e21be (patch)
tree12a45fa393c2ce35a1fdff7efc0a63ef7600b7cd /unotools
parentffbd3846d40eaf3dc8e8fa37e57d48ff7da88a5b (diff)
simplify LocalFileHelper::ConvertURLToPhysicalName
Diffstat (limited to 'unotools')
-rw-r--r--unotools/inc/unotools/localfilehelper.hxx9
-rw-r--r--unotools/source/config/defaultoptions.cxx4
-rw-r--r--unotools/source/config/pathoptions.cxx14
-rw-r--r--unotools/source/ucbhelper/localfilehelper.cxx30
-rw-r--r--unotools/source/ucbhelper/tempfile.cxx2
5 files changed, 27 insertions, 32 deletions
diff --git a/unotools/inc/unotools/localfilehelper.hxx b/unotools/inc/unotools/localfilehelper.hxx
index ebccc43d090c..9feed581d46e 100644
--- a/unotools/inc/unotools/localfilehelper.hxx
+++ b/unotools/inc/unotools/localfilehelper.hxx
@@ -44,7 +44,7 @@ namespace utl
If no UCP is available for the local file system, sal_False and an empty URL is returned.
Returning sal_True and an empty URL means that the URL doesn't point to a local file.
*/
- static sal_Bool ConvertPhysicalNameToURL( const String& rName, String& rReturn );
+ static bool ConvertPhysicalNameToURL(const rtl::OUString& rName, rtl::OUString& rReturn);
static sal_Bool ConvertSystemPathToURL( const String& rName, const String& rBaseURL, String& rReturn );
/**
@@ -53,12 +53,11 @@ namespace utl
otherwise sal_True and a valid URL, because a file name can always be converted if a UCP for the local
file system is present ( watch: this doesn't mean that this file really exists! )
*/
- static sal_Bool ConvertURLToPhysicalName( const String& rName, String& rReturn );
- static bool ConvertURLToPhysicalName( const rtl::OUString& rName, rtl::OUString& rReturn );
+ static bool ConvertURLToPhysicalName( const rtl::OUString& rName, rtl::OUString& rReturn );
static sal_Bool ConvertURLToSystemPath( const String& rName, String& rReturn );
- static sal_Bool IsLocalFile( const String& rName );
- static sal_Bool IsFileContent( const String& rName );
+ static sal_Bool IsLocalFile(const rtl::OUString& rName);
+ static sal_Bool IsFileContent(const rtl::OUString& rName);
static ::com::sun::star::uno::Sequence< ::rtl::OUString >
GetFolderContents( const ::rtl::OUString& rFolder, sal_Bool bFolder );
diff --git a/unotools/source/config/defaultoptions.cxx b/unotools/source/config/defaultoptions.cxx
index eb8c60068604..1b9d386c1bc1 100644
--- a/unotools/source/config/defaultoptions.cxx
+++ b/unotools/source/config/defaultoptions.cxx
@@ -199,7 +199,7 @@ void SvtDefaultOptions_Impl::Commit()
String SvtDefaultOptions_Impl::GetDefaultPath( sal_uInt16 nId ) const
{
- String aRet;
+ rtl::OUString aRet;
sal_uInt16 nIdx = 0;
while ( PathMap_Impl[nIdx]._ePath <= SvtPathOptions::PATH_WORK )
@@ -213,7 +213,7 @@ String SvtDefaultOptions_Impl::GetDefaultPath( sal_uInt16 nId ) const
nId == SvtPathOptions::PATH_MODULE ||
nId == SvtPathOptions::PATH_PLUGIN )
{
- String aTmp;
+ rtl::OUString aTmp;
::utl::LocalFileHelper::ConvertPhysicalNameToURL( aRet, aTmp );
aRet = aTmp;
}
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx
index 74f19ddaeef3..3be2d1ccea02 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -255,7 +255,7 @@ const String& SvtPathOptions_Impl::GetPath( SvtPathOptions::Pathes ePath )
try
{
OUString aPathValue;
- String aResult;
+ OUString aResult;
sal_Int32 nHandle = m_aMapEnumToPropHandle[ (sal_Int32)ePath ];
// Substitution is done by the service itself using the substition service
@@ -290,7 +290,7 @@ void SvtPathOptions_Impl::SetPath( SvtPathOptions::Pathes ePath, const String& r
if ( ePath < SvtPathOptions::PATH_COUNT )
{
- String aResult;
+ OUString aResult;
OUString aNewValue;
Any a;
@@ -413,7 +413,7 @@ OUString SvtPathOptions_Impl::SubstVar( const OUString& rVar ) const
if ( bConvertLocal )
{
// Convert the URL to a system path for special path variables
- String aReturn;
+ rtl::OUString aReturn;
utl::LocalFileHelper::ConvertURLToPhysicalName( aWorkText, aReturn );
return aReturn;
}
@@ -949,7 +949,7 @@ sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Pathes ePath )
if ( aObj.HasError() )
{
bIsURL = sal_False;
- String aURL;
+ rtl::OUString aURL;
if ( LocalFileHelper::ConvertPhysicalNameToURL( aPathToken, aURL ) )
aObj.SetURL( aURL );
}
@@ -978,8 +978,12 @@ sal_Bool SvtPathOptions::SearchFile( String& rIniFile, Pathes ePath )
if ( bRet )
{
if ( !bIsURL )
+ {
+ rtl::OUString sTmp(rIniFile);
::utl::LocalFileHelper::ConvertURLToPhysicalName(
- aObj.GetMainURL( INetURLObject::NO_DECODE ), rIniFile );
+ aObj.GetMainURL( INetURLObject::NO_DECODE ), sTmp );
+ rIniFile = sTmp;
+ }
else
rIniFile = aObj.GetMainURL( INetURLObject::NO_DECODE );
break;
diff --git a/unotools/source/ucbhelper/localfilehelper.cxx b/unotools/source/ucbhelper/localfilehelper.cxx
index b2c14cf268af..2d28dac1adc8 100644
--- a/unotools/source/ucbhelper/localfilehelper.cxx
+++ b/unotools/source/ucbhelper/localfilehelper.cxx
@@ -100,7 +100,7 @@ sal_Bool LocalFileHelper::ConvertURLToSystemPath( const String& rName, String& r
return ( rReturn.Len() != 0 );
}
-sal_Bool LocalFileHelper::ConvertPhysicalNameToURL( const String& rName, String& rReturn )
+bool LocalFileHelper::ConvertPhysicalNameToURL(const rtl::OUString& rName, rtl::OUString& rReturn)
{
rReturn = ::rtl::OUString();
::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get();
@@ -120,23 +120,15 @@ sal_Bool LocalFileHelper::ConvertPhysicalNameToURL( const String& rName, String&
rtl::OUString aBase( ::ucbhelper::getLocalFileURL( xManager ) );
rReturn = ::ucbhelper::getFileURLFromSystemPath( xManager, aBase, rName );
}
- catch ( ::com::sun::star::uno::RuntimeException& )
+ catch (const ::com::sun::star::uno::RuntimeException&)
{
}
}
- return ( rReturn.Len() != 0 );
-}
-
-bool LocalFileHelper::ConvertURLToPhysicalName( const rtl::OUString& rName, rtl::OUString& rReturn )
-{
- String aReturn;
- bool bReturn = ConvertURLToPhysicalName( rName, aReturn );
- rReturn = rtl::OUString( aReturn );
- return bReturn;
+ return !rReturn.isEmpty();
}
-sal_Bool LocalFileHelper::ConvertURLToPhysicalName( const String& rName, String& rReturn )
+bool LocalFileHelper::ConvertURLToPhysicalName(const rtl::OUString& rName, rtl::OUString& rReturn)
{
rReturn = ::rtl::OUString();
::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get();
@@ -157,24 +149,24 @@ sal_Bool LocalFileHelper::ConvertURLToPhysicalName( const String& rName, String&
if ( aObj.GetProtocol() == aLocal.GetProtocol() )
rReturn = ::ucbhelper::getSystemPathFromFileURL( xManager, rName );
}
- catch ( ::com::sun::star::uno::RuntimeException& )
+ catch (const ::com::sun::star::uno::RuntimeException&)
{
}
}
- return ( rReturn.Len() != 0 );
+ return !rReturn.isEmpty();
}
-sal_Bool LocalFileHelper::IsLocalFile( const String& rName )
+sal_Bool LocalFileHelper::IsLocalFile(const rtl::OUString& rName)
{
- String aTmp;
- return ConvertURLToPhysicalName( rName, aTmp );
+ rtl::OUString aTmp;
+ return ConvertURLToPhysicalName(rName, aTmp);
}
-sal_Bool LocalFileHelper::IsFileContent( const String& rName )
+sal_Bool LocalFileHelper::IsFileContent(const rtl::OUString& rName)
{
String aTmp;
- return ConvertURLToSystemPath( rName, aTmp );
+ return ConvertURLToSystemPath(rName, aTmp);
}
typedef ::std::vector< ::rtl::OUString* > StringList_Impl;
diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx
index 74c3c53db259..cc70904f55d4 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -411,7 +411,7 @@ String TempFile::GetURL() const
{
if ( !pImp->aURL.Len() )
{
- String aTmp;
+ rtl::OUString aTmp;
LocalFileHelper::ConvertPhysicalNameToURL( GetFileName(), aTmp );
pImp->aURL = aTmp;
}