ucb/source/ucp/cmis/cmis_content.cxx | 63 +++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 13 deletions(-)
New commits: commit fb6e0da4d86ff71e523ab78156cc1938ef00d4db Author: Mihai Varga <mihai.m...@gmail.com> Date: Mon Jul 28 11:41:48 2014 +0300 UNO to CMIS properties conversion fix The initial code always extracted Strings from the UNO instead of extracting the same data type that was written into it. This patch extracts the properties according to their data type and formats them to be reconstructed into CMIS properties. Change-Id: Ib160020e9d923a46e2c4f90924da847f2dac5e7a Reviewed-on: https://gerrit.libreoffice.org/10586 Reviewed-by: Bosdonnat Cedric <cedric.bosdon...@free.fr> Tested-by: Bosdonnat Cedric <cedric.bosdon...@free.fr> diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index 7cd9d3e..88b4784 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -48,6 +48,7 @@ #include <ucbhelper/std_outputstream.hxx> #include <ucbhelper/propertyvalueset.hxx> #include <ucbhelper/proxydecider.hxx> +#include <sax/tools/converter.hxx> #include "auth_provider.hxx" #include "certvalidation_handler.hxx" @@ -177,17 +178,66 @@ namespace bool bMultiValued = prop.MultiValued; bool bOpenChoice = prop.OpenChoice; uno::Any value = prop.Value; + std::vector< std::string > values; + libcmis::PropertyType::Type type = libcmis::PropertyType::String; if ( prop.Type == CMIS_TYPE_STRING ) + { + uno::Sequence< OUString > seqValue; + value >>= seqValue; + sal_Int32 m_nNumValue = seqValue.getLength( ); + for ( sal_Int32 i = 0; i < m_nNumValue; ++i ) + { + values.push_back( OUSTR_TO_STDSTR( seqValue[i] ) ); + } type = libcmis::PropertyType::String; + } else if ( prop.Type == CMIS_TYPE_BOOL ) + { + uno::Sequence< sal_Bool > seqValue; + value >>= seqValue; + sal_Int32 m_nNumValue = seqValue.getLength( ); + for ( sal_Int32 i = 0; i < m_nNumValue; ++i ) + { + values.push_back( OUSTR_TO_STDSTR( OUString::boolean( seqValue[i] ) ) ); + } type = libcmis::PropertyType::Bool; + } else if ( prop.Type == CMIS_TYPE_INTEGER ) + { + uno::Sequence< sal_Int64 > seqValue; + value >>= seqValue; + sal_Int32 m_nNumValue = seqValue.getLength( ); + for ( sal_Int32 i = 0; i < m_nNumValue; ++i ) + { + values.push_back( OUSTR_TO_STDSTR( OUString::number( seqValue[i] ) ) ); + } type = libcmis::PropertyType::Integer; + } else if ( prop.Type == CMIS_TYPE_DECIMAL ) + { + uno::Sequence< double > seqValue; + value >>= seqValue; + sal_Int32 m_nNumValue = seqValue.getLength( ); + for ( sal_Int32 i = 0; i < m_nNumValue; ++i ) + { + values.push_back( OUSTR_TO_STDSTR( OUString::number( seqValue[i] ) ) ); + } type = libcmis::PropertyType::Decimal; + } else if ( prop.Type == CMIS_TYPE_DATETIME ) + { + uno::Sequence< util::DateTime > seqValue; + value >>= seqValue; + sal_Int32 m_nNumValue = seqValue.getLength( ); + for ( sal_Int32 i = 0; i < m_nNumValue; ++i ) + { + OUStringBuffer aBuffer; + ::sax::Converter::convertDateTime( aBuffer, seqValue[i], 0, false ); + values.push_back( OUSTR_TO_STDSTR( aBuffer.makeStringAndClear( ) ) ); + } type = libcmis::PropertyType::DateTime; + } propertyType->setId( OUSTR_TO_STDSTR( id )); propertyType->setDisplayName( OUSTR_TO_STDSTR( name ) ); @@ -197,23 +247,10 @@ namespace propertyType->setOpenChoice( bOpenChoice ); propertyType->setType( type ); - std::vector< std::string > values; - - // convert UNO value to string vector - 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 ); - } - libcmis::PropertyPtr property( new libcmis::Property( propertyType, values ) ); return property; } - } namespace cmis _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits