diff options
author | Jan Holesovsky <kendy@suse.cz> | 2013-01-04 23:09:18 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2013-01-04 23:44:04 +0100 |
commit | c223e5ff859171adab1597025b30ec2501fc5771 (patch) | |
tree | 6fcaf14a527b2bb8197885c8377dae78ba254002 /cui/source/options/personalization.cxx | |
parent | cc84ff4a51790f52f2e729cc61f7515fbbd51f35 (diff) |
Personas: More robust Persona URL handling.
Change-Id: I55fa2570decd52e978747e589887f2fe972812c8
Diffstat (limited to 'cui/source/options/personalization.cxx')
-rw-r--r-- | cui/source/options/personalization.cxx | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/cui/source/options/personalization.cxx b/cui/source/options/personalization.cxx index 7d31b0fa4cc0..ae8f60572f3d 100644 --- a/cui/source/options/personalization.cxx +++ b/cui/source/options/personalization.cxx @@ -71,7 +71,14 @@ OUString SelectPersonaDialog::GetPersonaURL() const return OUString(); } - return aText; + // canonicalize the URL + OUString aPersona( "persona/" ); + sal_Int32 nPersona = aText.lastIndexOf( aPersona ); + + if ( nPersona < 0 ) + return OUString(); + + return "http://www.getpersonas.com/persona/" + aText.copy( nPersona + aPersona.getLength() ); } IMPL_LINK( SelectPersonaDialog, VisitPersonas, PushButton*, /*pButton*/ ) @@ -236,7 +243,7 @@ IMPL_LINK( SvxPersonalizationTabPage, SelectPersona, PushButton*, /*pButton*/ ) while ( aDialog.Execute() == RET_OK ) { OUString aURL( aDialog.GetPersonaURL() ); - if ( aURL != "" ) + if ( !aURL.isEmpty() ) { if ( CopyPersonaToGallery( aURL ) ) m_pOwnPersona->Check(); @@ -312,7 +319,14 @@ bool SvxPersonalizationTabPage::CopyPersonaToGallery( const OUString &rURL ) if ( !xFileAccess.is() ) return false; - uno::Reference< io::XInputStream > xStream( xFileAccess->openFileRead( rURL ), uno::UNO_QUERY ); + uno::Reference< io::XInputStream > xStream; + try { + xStream = xFileAccess->openFileRead( rURL ); + } + catch (...) + { + return false; + } if ( !xStream.is() ) return false; |