ucb/source/ucp/cmis/cmis_content.cxx |   63 +++++++++++++++++++++++++++++++++--
 1 file changed, 61 insertions(+), 2 deletions(-)

New commits:
commit 86d3cebe0711bb1c643fa24b22c4761e237b3c64
Author: Cao Cuong Ngo <cao.cuong....@gmail.com>
Date:   Wed Jul 10 10:40:48 2013 +0200

    CMIS properties dialog
    
    Convert Any to Cmis properties
    
    Change-Id: I307d337363a84bae8585625ee3eeb641fde25792

diff --git a/ucb/source/ucp/cmis/cmis_content.cxx 
b/ucb/source/ucp/cmis/cmis_content.cxx
index 370b402..cbce84b 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
         {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to