Kaydet (Commit) d259e07e authored tarafından Cao Cuong Ngo's avatar Cao Cuong Ngo Kaydeden (comit) Cédric Bosdonnat

CMIS properties dialog: update properties

Change-Id: Ia506713b61dc6c1343eac3640863c86a2fc3f18f
üst b56a9a22
......@@ -164,6 +164,10 @@ public:
const com::sun::star::uno::Any& rValue );
std::vector< CmisProperty* > GetCmisProperties() const;
::com::sun::star::uno::Sequence< ::com::sun::star::document::CmisProperty >
GetCmisPropertiesSeq() const;
void ClearCmisProperties();
void AddCmisProperty( const OUString& sId, const OUString& sName,
const bool bUpdatable, const bool bRequired,
......
......@@ -1316,6 +1316,11 @@ public:
css::document::CmisProperty >& _cmisproperties )
throw (css::uno::RuntimeException);
virtual void SAL_CALL updateCmisProperties(
const css::uno::Sequence<
css::document::CmisProperty >& _cmisproperties )
throw (css::uno::RuntimeException);
virtual void SAL_CALL checkOut( ) throw ( css::uno::RuntimeException );
virtual void SAL_CALL cancelCheckOut( ) throw ( css::uno::RuntimeException );
virtual void SAL_CALL checkIn( sal_Bool bIsMajor, const OUString & rMessage )
......
......@@ -44,6 +44,8 @@ interface XCmisDocument : com::sun::star::uno::XInterface
boolean canCheckIn( );
void updateCmisProperties( [in] sequence <com::sun::star::document::CmisProperty> cmisProperties );
/** Contains the properties values named after their CMIS ID.
*/
[attribute] sequence <com::sun::star::document::CmisProperty> CmisProperties;
......
......@@ -576,6 +576,28 @@ std::vector< CmisProperty* > SfxDocumentInfoItem::GetCmisProperties() const
return aRet;
}
uno::Sequence< document::CmisProperty > SfxDocumentInfoItem::GetCmisPropertiesSeq() const
{
Sequence< document::CmisProperty > aPropertiesSeq( m_aCmisProperties.size() );
sal_Int32 i = 0;
std::vector< CmisProperty* >::const_iterator pIter;
for ( pIter = m_aCmisProperties.begin();
pIter != m_aCmisProperties.end(); ++pIter, ++i )
{
CmisProperty* aProp = *pIter;
aPropertiesSeq[i].Id = aProp->m_sId;
aPropertiesSeq[i].Name = aProp->m_sName;
aPropertiesSeq[i].Updatable = aProp->m_bUpdatable;
aPropertiesSeq[i].Required = aProp->m_bRequired;
aPropertiesSeq[i].MultiValued = aProp->m_bMultiValued;
aPropertiesSeq[i].OpenChoice = aProp->m_bOpenChoice;
aPropertiesSeq[i].Choices = aProp->m_aChoices;
aPropertiesSeq[i].Value = aProp->m_aValue;
}
return aPropertiesSeq;
}
void SfxDocumentInfoItem::ClearCmisProperties()
{
for ( sal_uInt32 i = 0; i < m_aCmisProperties.size(); i++ )
......
......@@ -518,10 +518,13 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
{
// user has done some changes to DocumentInfo
pDocInfoItem->UpdateDocumentInfo(getDocProperties());
uno::Sequence< document::CmisProperty > aNewCmisProperties =
pDocInfoItem->GetCmisPropertiesSeq( );
xCmisDoc->updateCmisProperties( aNewCmisProperties );
SetUseUserData( ((const SfxDocumentInfoItem *)pDocInfoItem)->IsUseUserData() );
// add data from dialog for possible recording purpose
rReq.AppendItem( SfxDocumentInfoItem( GetTitle(),
getDocProperties(), aCmisProperties, IsUseUserData() ) );
getDocProperties(), aNewCmisProperties, IsUseUserData() ) );
}
rReq.Done();
......
......@@ -2474,6 +2474,29 @@ void SAL_CALL SfxBaseModel::setCmisProperties( const Sequence< document::CmisPro
m_pData->m_cmisProperties = _cmisproperties;
}
void SAL_CALL SfxBaseModel::updateCmisProperties( const Sequence< document::CmisProperty >& aProperties )
throw ( RuntimeException )
{
SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium();
if ( pMedium )
{
try
{
::ucbhelper::Content aContent( pMedium->GetName( ),
Reference<ucb::XCommandEnvironment>(),
comphelper::getProcessComponentContext() );\
aContent.executeCommand( "updateProperties", uno::makeAny( aProperties ) );
loadCmisProperties( );
}
catch (const Exception & e)
{
throw RuntimeException( e.Message, e.Context );
}
}
}
void SAL_CALL SfxBaseModel::checkOut( ) throw ( RuntimeException )
{
SfxMedium* pMedium = m_pData->m_pObjectShell->GetMedium();
......
......@@ -413,6 +413,25 @@ namespace cmis
static_cast< cppu::OWeakObject * >( this ), -1) );
}
libcmis::ObjectPtr Content::updateProperties(
const uno::Any& /*iCmisProps*/,
const uno::Reference< ucb::XCommandEnvironment >& xEnv )
{
// TODO convert iCmisProps to aProperties;
map< string, libcmis::PropertyPtr > aProperties;
libcmis::ObjectPtr updateObj;
try
{
updateObj = getObject( xEnv )->updateProperties( aProperties );
}
catch ( const libcmis::Exception& e )
{
SAL_INFO( "cmisucp", "Unexpected libcmis exception: "<< e.what( ) );
}
return updateObj;
}
uno::Reference< sdbc::XRow > Content::getPropertyValues(
const uno::Sequence< beans::Property >& rProperties,
const uno::Reference< ucb::XCommandEnvironment >& xEnv )
......@@ -1328,6 +1347,8 @@ namespace cmis
ucb::CommandInfo ( OUString( "cancelCheckout" ), -1, getCppuVoidType() ),
ucb::CommandInfo ( OUString( "checkIn" ), -1,
getCppuType( static_cast<ucb::TransferInfo * >( 0 ) ) ),
ucb::CommandInfo ( OUString( "updateProperties" ), -1, getCppuVoidType() ),
// Folder Only, omitted if not a folder
ucb::CommandInfo
......@@ -1535,6 +1556,10 @@ namespace cmis
}
aRet <<= checkIn( aArg, xEnv );
}
else if ( aCommand.Name == "updateProperties" )
{
updateProperties( aCommand.Argument, xEnv );
}
else
{
SAL_INFO( "cmisucp", "Unknown command to execute" );
......
......@@ -140,6 +140,11 @@ public:
getProperties( const com::sun::star::uno::Reference<
com::sun::star::ucb::XCommandEnvironment > & xEnv );
virtual libcmis::ObjectPtr updateProperties(
const com::sun::star::uno::Any& iCmisProps,
const com::sun::star::uno::Reference<
com::sun::star::ucb::XCommandEnvironment > & xEnv);
virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
getCommands( const com::sun::star::uno::Reference<
com::sun::star::ucb::XCommandEnvironment > & xEnv );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment