summaryrefslogtreecommitdiff
path: root/ucb/source
diff options
context:
space:
mode:
authorMihai Varga <mihai.mv13@gmail.com>2014-07-28 11:41:48 +0300
committerBosdonnat Cedric <cedric.bosdonnat@free.fr>2014-07-28 09:03:17 +0000
commitfb6e0da4d86ff71e523ab78156cc1938ef00d4db (patch)
treed11266a653cd73730be7346a066373579e2709aa /ucb/source
parent5b66024c117f2c354dda5c928f09d4cc21403b51 (diff)
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.bosdonnat@free.fr> Tested-by: Bosdonnat Cedric <cedric.bosdonnat@free.fr>
Diffstat (limited to 'ucb/source')
-rw-r--r--ucb/source/ucp/cmis/cmis_content.cxx63
1 files changed, 50 insertions, 13 deletions
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx
index 7cd9d3e7170f..88b47847f606 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