From 7c29619b4673465b5f2dd589e5d6fb8234364397 Mon Sep 17 00:00:00 2001 From: Cao Cuong Ngo Date: Wed, 10 Jul 2013 10:40:48 +0200 Subject: CMIS properties dialog Convert Any to Cmis properties Change-Id: I307d337363a84bae8585625ee3eeb641fde25792 --- ucb/source/ucp/cmis/cmis_content.cxx | 63 ++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) (limited to 'ucb') diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index 3b0093ff2022..45ae0cef48e3 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -194,6 +194,55 @@ namespace } return aValue; } + + libcmis::PropertyPtr lcl_unoToCmisProperty( document::CmisProperty prop ) + { + libcmis::PropertyTypePtr propertyType( new libcmis::PropertyType( ) ); + + OUString id = prop.Id; + OUString name = prop.Name; + bool bUpdatable = prop.Updatable; + bool bRequired = prop.Required; + bool bMultiValued = prop.MultiValued; + bool bOpenChoice = prop.OpenChoice; + uno::Any value = prop.Value; + libcmis::PropertyType::Type type = libcmis::PropertyType::String; + + propertyType->setId( OUSTR_TO_STDSTR( id )); + propertyType->setDisplayName( OUSTR_TO_STDSTR( name ) ); + propertyType->setUpdatable( bUpdatable ); + propertyType->setRequired( bRequired ); + propertyType->setMultiValued( bMultiValued ); + propertyType->setOpenChoice( bOpenChoice ); + propertyType->setType( type ); + + std::vector< std::string > values; + + // convert UNO value to string vector + if ( bMultiValued ) + { + uno::Sequence< OUString > aStrings; + value >>= aStrings; + sal_Int32 len = aStrings.getLength( ); + for ( sal_Int32 i = 0; i < len; i++ ) + { + string str = OUSTR_TO_STDSTR( aStrings[i] ); + values.push_back( str ); + } + } + else + { + OUString val; + value >>= val; + std::string str = OUSTR_TO_STDSTR( val ); + values.push_back( str); + } + + libcmis::PropertyPtr property( new libcmis::Property( propertyType, values ) ); + + return property; + } + } namespace cmis @@ -414,11 +463,21 @@ namespace cmis } libcmis::ObjectPtr Content::updateProperties( - const uno::Any& /*iCmisProps*/, + const uno::Any& iCmisProps, const uno::Reference< ucb::XCommandEnvironment >& xEnv ) { - // TODO convert iCmisProps to aProperties; + // Convert iCmisProps to Cmis Properties; + uno::Sequence< document::CmisProperty > aPropsSeq; + iCmisProps >>= aPropsSeq; map< string, libcmis::PropertyPtr > aProperties; + + sal_Int32 propsLen = aPropsSeq.getLength( ); + for ( sal_Int32 i = 0; i< propsLen; i++ ) + { + std::string id = OUSTR_TO_STDSTR( aPropsSeq[i].Id ); + libcmis::PropertyPtr prop = lcl_unoToCmisProperty( aPropsSeq[i] ); + aProperties.insert( std::pair( id, prop ) ); + } libcmis::ObjectPtr updateObj; try { -- cgit