summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCao Cuong Ngo <cao.cuong.ngo@gmail.com>2013-07-10 10:40:48 +0200
committerCao Cuong Ngo <cao.cuong.ngo@gmail.com>2013-07-10 12:39:36 +0200
commit86d3cebe0711bb1c643fa24b22c4761e237b3c64 (patch)
treed453a76264202d730c6f78a7a359884cf1dff31d
parentb9383942694097fd1fa243fe6a5f1962ab3f3671 (diff)
CMIS properties dialog
Convert Any to Cmis properties Change-Id: I307d337363a84bae8585625ee3eeb641fde25792
-rw-r--r--ucb/source/ucp/cmis/cmis_content.cxx63
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 370b402c991e..cbce84b82887 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -197,6 +197,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
@@ -417,11 +466,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
{