From a080fcbc00bbbb14e92f1850ef9c79d2c833b646 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Tue, 8 Jun 2010 16:26:01 +0200 Subject: #i112173# - Handle keyinput for delete according to actual content properties. --- svtools/source/contnr/fileview.cxx | 67 ++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 13 deletions(-) (limited to 'svtools/source/contnr') diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx index 73a0aac06f3f..fa4af2896994 100644 --- a/svtools/source/contnr/fileview.cxx +++ b/svtools/source/contnr/fileview.cxx @@ -1006,12 +1006,31 @@ void ViewTabListBox_Impl::DeleteEntries() aURL = ( (SvtContentEntry*)pCurEntry->GetUserData() )->maURL; if ( !aURL.Len() ) - return; + continue; + + bool canDelete = true; + try + { + ::ucbhelper::Content aCnt( aURL, mxCmdEnv ); + Reference< XCommandInfo > aCommands = aCnt.getCommands(); + if ( aCommands.is() ) + canDelete + = aCommands->hasCommandByName( + OUString::createFromAscii( "delete" ) ); + else + canDelete = false; + } + catch( Exception const & ) + { + canDelete = false; + } - INetURLObject aObj( aURL ); + if (!canDelete) + continue; // process next entry if ( eResult != svtools::QUERYDELETE_ALL ) { + INetURLObject aObj( aURL ); svtools::QueryDeleteDlg_Impl aDlg( NULL, aObj.GetName( INetURLObject::DECODE_WITH_CHARSET ) ); if ( sDialogPosition.Len() ) aDlg.SetWindowState( sDialogPosition ); @@ -1057,22 +1076,44 @@ BOOL ViewTabListBox_Impl::EditedEntry( SvLBoxEntry* pEntry, try { + OUString aPropName = OUString::createFromAscii( "Title" ); + bool canRename = true; ::ucbhelper::Content aContent( aURL, mxCmdEnv ); - OUString aPropName = OUString::createFromAscii( "Title" ); - Any aValue; - aValue <<= OUString( rNewText ); - aContent.setPropertyValue( aPropName, aValue ); - mpParent->EntryRenamed( aURL, rNewText ); + try + { + Reference< XPropertySetInfo > aProps = aContent.getProperties(); + if ( aProps.is() ) + { + Property aProp = aProps->getPropertyByName( aPropName ); + canRename = !( aProp.Attributes & PropertyAttribute::READONLY ); + } + else + { + canRename = false; + } + } + catch ( Exception const & ) + { + canRename = false; + } + + if ( canRename ) + { + Any aValue; + aValue <<= OUString( rNewText ); + aContent.setPropertyValue( aPropName, aValue ); + mpParent->EntryRenamed( aURL, rNewText ); - pData->maURL = aURL; - pEntry->SetUserData( pData ); + pData->maURL = aURL; + pEntry->SetUserData( pData ); - bRet = TRUE; + bRet = TRUE; + } + } + catch( Exception const & ) + { } - //catch( ::com::sun::star::ucb::ContentCreationException const & ) {} - //catch( ::com::sun::star::ucb::CommandAbortedException const & ) {} - catch( Exception const & ) {} return bRet; } -- cgit v1.2.3