diff options
author | Cao Cuong Ngo <cao.cuong.ngo@gmail.com> | 2013-07-10 10:40:48 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr> | 2013-09-02 13:51:49 +0200 |
commit | 7c29619b4673465b5f2dd589e5d6fb8234364397 (patch) | |
tree | fa5f6cb00cedf1dcd8fd2cefce5fa79622ee9d8b /ucb/source | |
parent | d259e07e851cafa4e0ca68f7ab18535e82c7aed5 (diff) |
CMIS properties dialog
Convert Any to Cmis properties
Change-Id: I307d337363a84bae8585625ee3eeb641fde25792
Diffstat (limited to 'ucb/source')
-rw-r--r-- | ucb/source/ucp/cmis/cmis_content.cxx | 63 |
1 files changed, 61 insertions, 2 deletions
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<string, libcmis::PropertyPtr>( id, prop ) ); + } libcmis::ObjectPtr updateObj; try { |