diff options
author | Cao Cuong Ngo <cao.cuong.ngo@gmail.com> | 2013-08-23 15:43:03 +0200 |
---|---|---|
committer | Cédric Bosdonnat <cedric.bosdonnat.ooo@free.fr> | 2013-09-02 13:51:56 +0200 |
commit | 5c1d9086db52d31f9242c93a9304d90bf56b4219 (patch) | |
tree | 387ed04b533a715ba162fd4753795cd729309c16 | |
parent | b5e2d83bd529b0f0ce04d0690f4e0cccb667931e (diff) |
CMIS properties dialog: get multiple values
Change-Id: Ife7562d52cc3070c8d409f2da68d4e2aa5faea69
-rw-r--r-- | sfx2/source/dialog/dinfdlg.cxx | 25 | ||||
-rw-r--r-- | ucb/source/ucp/cmis/cmis_content.cxx | 136 |
2 files changed, 57 insertions, 104 deletions
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx index ef7bdbca2531..6b1f06ba6177 100644 --- a/sfx2/source/dialog/dinfdlg.cxx +++ b/sfx2/source/dialog/dinfdlg.cxx @@ -2220,43 +2220,42 @@ void CmisPropertiesWindow::AddLine( const OUString& sId, const OUString& sName, pNewLine->m_aName->SetText( sName ); - SvtSysLocale aSysLocale; - const LocaleDataWrapper& rLocaleWrapper = aSysLocale.GetLocaleData(); OUString sValue; if ( sType == CMIS_TYPE_INTEGER ) { - sal_Int64 nTmpValue = 0; + Sequence< sal_Int64 > nTmpValue; rAny >>= nTmpValue; sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM ); - m_aNumberFormatter.GetInputLineString( nTmpValue, nIndex, sValue ); + m_aNumberFormatter.GetInputLineString( nTmpValue[0], nIndex, sValue ); } else if ( sType == CMIS_TYPE_DECIMAL ) { - double dTmpValue = 0.0; + Sequence< double > dTmpValue; rAny >>= dTmpValue; sal_uInt32 nIndex = m_aNumberFormatter.GetFormatIndex( NF_NUMBER_SYSTEM ); - m_aNumberFormatter.GetInputLineString( dTmpValue, nIndex, sValue ); + m_aNumberFormatter.GetInputLineString( dTmpValue[0], nIndex, sValue ); } else if ( sType == CMIS_TYPE_BOOL ) { - bool bTmpValue = false; + Sequence< bool > bTmpValue; rAny >>= bTmpValue; - sValue = ( bTmpValue ? rLocaleWrapper.getTrueWord() : rLocaleWrapper.getFalseWord() ); - if ( bTmpValue ) + if ( bTmpValue[0] ) pNewLine->m_aYesButton->Check(); else pNewLine->m_aNoButton->Check(); } else if ( sType == CMIS_TYPE_STRING ) { - rAny >>= sValue; + Sequence< OUString > seqValue; + rAny >>= seqValue; + sValue = seqValue[0]; } else if ( sType == CMIS_TYPE_DATETIME ) { - util::DateTime aTmpDateTime; + Sequence< util::DateTime > aTmpDateTime; rAny >>= aTmpDateTime; - pNewLine->m_aDateField->SetDate( Date( aTmpDateTime.Day, aTmpDateTime.Month, aTmpDateTime.Year ) ); - pNewLine->m_aTimeField->SetTime( Time( aTmpDateTime.Hours, aTmpDateTime.Minutes, aTmpDateTime.Seconds, aTmpDateTime.NanoSeconds ) ); + pNewLine->m_aDateField->SetDate( Date( aTmpDateTime[0].Day, aTmpDateTime[0].Month, aTmpDateTime[0].Year ) ); + pNewLine->m_aTimeField->SetTime( Time( aTmpDateTime[0].Hours, aTmpDateTime[0].Minutes, aTmpDateTime[0].Seconds, aTmpDateTime[0].NanoSeconds ) ); } diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index f2048a0324e4..e6d213d6fe56 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -82,114 +82,78 @@ namespace uno::Any lcl_cmisPropertyToUno( libcmis::PropertyPtr pProperty ) { uno::Any aValue; - bool bMultiValued = pProperty->getPropertyType( )->isMultiValued( ); switch ( pProperty->getPropertyType( )->getType( ) ) { default: case libcmis::PropertyType::String: { vector< string > aCmisStrings = pProperty->getStrings( ); - if ( bMultiValued ) + uno::Sequence< OUString > aStrings( aCmisStrings.size( ) ); + OUString* aStringsArr = aStrings.getArray( ); + sal_Int32 i = 0; + for ( vector< string >::iterator it = aCmisStrings.begin( ); + it != aCmisStrings.end( ); ++it, ++i ) { - uno::Sequence< OUString > aStrings( aCmisStrings.size( ) ); - OUString* aStringsArr = aStrings.getArray( ); - sal_Int32 i = 0; - for ( vector< string >::iterator it = aCmisStrings.begin( ); - it != aCmisStrings.end( ); ++it, ++i ) - { - string str = *it; - aStringsArr[i] = STD_TO_OUSTR( str ); - } - aValue <<= aStrings; - } - else if ( !aCmisStrings.empty( ) ) - { - aValue <<= STD_TO_OUSTR( aCmisStrings.front( ) ); + string str = *it; + aStringsArr[i] = STD_TO_OUSTR( str ); } + aValue <<= aStrings; } break; case libcmis::PropertyType::Integer: { vector< long > aCmisLongs = pProperty->getLongs( ); - if ( bMultiValued ) + uno::Sequence< sal_Int64 > aLongs( aCmisLongs.size( ) ); + sal_Int64* aLongsArr = aLongs.getArray( ); + sal_Int32 i = 0; + for ( vector< long >::iterator it = aCmisLongs.begin( ); + it != aCmisLongs.end( ); ++it, ++i ) { - uno::Sequence< sal_Int64 > aLongs( aCmisLongs.size( ) ); - sal_Int64* aLongsArr = aLongs.getArray( ); - sal_Int32 i = 0; - for ( vector< long >::iterator it = aCmisLongs.begin( ); - it != aCmisLongs.end( ); ++it, ++i ) - { - aLongsArr[i] = *it; - } - aValue <<= aLongs; - } - else if ( !aCmisLongs.empty( ) ) - { - aValue <<= aCmisLongs.front( ); + aLongsArr[i] = *it; } + aValue <<= aLongs; } break; case libcmis::PropertyType::Decimal: { vector< double > aCmisDoubles = pProperty->getDoubles( ); - if ( bMultiValued ) - { - uno::Sequence< double > aDoubles( aCmisDoubles.size( ) ); - double* aDoublesArr = aDoubles.getArray( ); - sal_Int32 i = 0; - for ( vector< double >::iterator it = aCmisDoubles.begin( ); - it != aCmisDoubles.end( ); ++it, ++i ) - { - aDoublesArr[i] = *it; - } - aValue <<= aDoubles; - } - else if ( !aCmisDoubles.empty( ) ) + uno::Sequence< double > aDoubles( aCmisDoubles.size( ) ); + double* aDoublesArr = aDoubles.getArray( ); + sal_Int32 i = 0; + for ( vector< double >::iterator it = aCmisDoubles.begin( ); + it != aCmisDoubles.end( ); ++it, ++i ) { - aValue <<= aCmisDoubles.front( ); + aDoublesArr[i] = *it; } + aValue <<= aDoubles; } break; case libcmis::PropertyType::Bool: { vector< bool > aCmisBools = pProperty->getBools( ); - if ( bMultiValued ) + uno::Sequence< sal_Bool > aBools( aCmisBools.size( ) ); + sal_Bool* aBoolsArr = aBools.getArray( ); + sal_Int32 i = 0; + for ( vector< bool >::iterator it = aCmisBools.begin( ); + it != aCmisBools.end( ); ++it, ++i ) { - uno::Sequence< sal_Bool > aBools( aCmisBools.size( ) ); - sal_Bool* aBoolsArr = aBools.getArray( ); - sal_Int32 i = 0; - for ( vector< bool >::iterator it = aCmisBools.begin( ); - it != aCmisBools.end( ); ++it, ++i ) - { - aBoolsArr[i] = *it; - } - aValue <<= aBools; - } - else if ( !aCmisBools.empty( ) ) - { - aValue <<= sal_Bool( aCmisBools.front( ) ); + aBoolsArr[i] = *it; } + aValue <<= aBools; } break; case libcmis::PropertyType::DateTime: { vector< boost::posix_time::ptime > aCmisTimes = pProperty->getDateTimes( ); - if ( bMultiValued ) + uno::Sequence< util::DateTime > aTimes( aCmisTimes.size( ) ); + util::DateTime* aTimesArr = aTimes.getArray( ); + sal_Int32 i = 0; + for ( vector< boost::posix_time::ptime >::iterator it = aCmisTimes.begin( ); + it != aCmisTimes.end( ); ++it, ++i ) { - uno::Sequence< util::DateTime > aTimes( aCmisTimes.size( ) ); - util::DateTime* aTimesArr = aTimes.getArray( ); - sal_Int32 i = 0; - for ( vector< boost::posix_time::ptime >::iterator it = aCmisTimes.begin( ); - it != aCmisTimes.end( ); ++it, ++i ) - { - aTimesArr[i] = lcl_boostToUnoTime( *it ); - } - aValue <<= aTimes; - } - else if ( !aCmisTimes.empty( ) ) - { - aValue <<= lcl_boostToUnoTime( aCmisTimes.front( ) ); + aTimesArr[i] = lcl_boostToUnoTime( *it ); } + aValue <<= aTimes; } break; } @@ -212,11 +176,11 @@ namespace type = libcmis::PropertyType::String; else if ( prop.Type == CMIS_TYPE_BOOL ) type = libcmis::PropertyType::Bool; - else if ( prop.Type == CMIS_TYPE_INTEGER ) + else if ( prop.Type == CMIS_TYPE_INTEGER ) type = libcmis::PropertyType::Integer; - else if ( prop.Type == CMIS_TYPE_DECIMAL ) + else if ( prop.Type == CMIS_TYPE_DECIMAL ) type = libcmis::PropertyType::Decimal; - else if ( prop.Type == CMIS_TYPE_DATETIME ) + else if ( prop.Type == CMIS_TYPE_DATETIME ) type = libcmis::PropertyType::DateTime; propertyType->setId( OUSTR_TO_STDSTR( id )); @@ -230,23 +194,13 @@ namespace 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 + uno::Sequence< OUString > aStrings; + value >>= aStrings; + sal_Int32 len = aStrings.getLength( ); + for ( sal_Int32 i = 0; i < len; i++ ) { - OUString val; - value >>= val; - std::string str = OUSTR_TO_STDSTR( val ); - values.push_back( str); + string str = OUSTR_TO_STDSTR( aStrings[i] ); + values.push_back( str ); } libcmis::PropertyPtr property( new libcmis::Property( propertyType, values ) ); |