diff options
-rw-r--r-- | offapi/UnoApi_offapi.mk | 1 | ||||
-rw-r--r-- | offapi/com/sun/star/document/XCmisDocument.idl | 35 | ||||
-rw-r--r-- | sfx2/inc/sfx2/sfxbasemodel.hxx | 27 | ||||
-rw-r--r-- | sfx2/source/doc/objstor.cxx | 21 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 28 | ||||
-rw-r--r-- | ucb/source/ucp/cmis/cmis_content.cxx | 171 |
6 files changed, 279 insertions, 4 deletions
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 442b4b78be93..a505169ab1c2 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -2131,6 +2131,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,offapi/com/sun/star/document,\ UpdateDocMode \ XActionLockable \ XBinaryStreamResolver \ + XCmisDocument \ XCodeNameQuery \ XCompatWriterDocProperties \ XDocumentEventBroadcaster \ diff --git a/offapi/com/sun/star/document/XCmisDocument.idl b/offapi/com/sun/star/document/XCmisDocument.idl new file mode 100644 index 000000000000..246a1b7f3d10 --- /dev/null +++ b/offapi/com/sun/star/document/XCmisDocument.idl @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef __com_sun_star_document_XCmisDataSupplier_idl__ +#define __com_sun_star_document_XCmisDataSupplier_idl__ + +#include <com/sun/star/beans/PropertyValues.idl> +#include <com/sun/star/uno/XInterface.idl> + +module com { module sun { module star { module document { + +/** The document can provide access to CMIS properties and versions + through this interface. + */ +interface XCmisDocument : com::sun::star::uno::XInterface +{ + /** Contains the properties values named after their CMIS ID. + */ + [attribute] com::sun::star::beans::PropertyValues CmisPropertiesValues; + + /** Contains the property names to show to the user from their CMIS id. + */ + [attribute] com::sun::star::beans::PropertyValues CmisPropertiesDisplayNames; +}; + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/inc/sfx2/sfxbasemodel.hxx b/sfx2/inc/sfx2/sfxbasemodel.hxx index 0fae6b8c766d..8b7097f4ff68 100644 --- a/sfx2/inc/sfx2/sfxbasemodel.hxx +++ b/sfx2/inc/sfx2/sfxbasemodel.hxx @@ -32,6 +32,7 @@ #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XNameReplace.hpp> #include <com/sun/star/frame/XController2.hpp> +#include <com/sun/star/document/XCmisDocument.hpp> #include <com/sun/star/document/XDocumentInfo.hpp> #include <com/sun/star/document/XDocumentInfoSupplier.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> @@ -87,9 +88,9 @@ #include <com/sun/star/task/XInteractionHandler.hpp> //________________________________________________________________________________________________________ -#ifndef INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_32 -#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_32 -#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 32 +#ifndef INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_33 +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_33 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 33 #include <comphelper/implbase_var.hxx> #endif @@ -209,9 +210,10 @@ namespace sfx { namespace intern { SfxListener */ -typedef ::comphelper::WeakImplHelper32 < XCHILD +typedef ::comphelper::WeakImplHelper33 < XCHILD , XDOCUMENTINFOSUPPLIER , ::com::sun::star::document::XDocumentPropertiesSupplier + , ::com::sun::star::document::XCmisDocument , ::com::sun::star::rdf::XDocumentMetadataAccess , ::com::sun::star::document::XDocumentRecovery , ::com::sun::star::document::XUndoManagerSupplier @@ -1402,6 +1404,23 @@ public: ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException); + // XCmisDocument + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > + SAL_CALL getCmisPropertiesValues() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCmisPropertiesValues( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& _cmispropertiesvalues ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > + SAL_CALL getCmisPropertiesDisplayNames() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCmisPropertiesDisplayNames( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& _cmispropertiesdisplaynames ) + throw (::com::sun::star::uno::RuntimeException); + //____________________________________________________________________________________________________ // SfxListener diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index b9b5f0480551..ec6b25236f86 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -29,6 +29,7 @@ #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/document/XCmisDocument.hpp> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> #include <com/sun/star/document/XExporter.hpp> @@ -744,6 +745,26 @@ sal_Bool SfxObjectShell::DoLoad( SfxMedium *pMed ) com::sun::star::uno::Reference < XPropertySetInfo > xProps = aContent.getProperties(); if ( xProps.is() ) { + // Copy all the CMIS properties to the document (if there is any) + ::rtl::OUString aCmisPropsValues( "CmisPropertiesValues" ); + ::rtl::OUString aCmisPropsNames( "CmisPropertiesDisplayNames" ); + uno::Reference< document::XCmisDocument > xCmisDoc( GetModel( ), uno::UNO_QUERY_THROW ); + if ( xProps->hasPropertyByName( aCmisPropsValues ) ) + { + beans::PropertyValues aCmisValues; + aContent.getPropertyValue( aCmisPropsValues ) >>= aCmisValues; + xCmisDoc->setCmisPropertiesValues( aCmisValues ); + + // TODO For CMIS case, try to look for cmis:isVersionSeriesCheckedOut + // If set to false, then show InfoBar to propose checkOut + } + if ( xProps->hasPropertyByName( aCmisPropsNames ) ) + { + beans::PropertyValues aPropNames; + aContent.getPropertyValue( aCmisPropsNames ) >>= aPropNames; + xCmisDoc->setCmisPropertiesDisplayNames( aPropNames ); + } + ::rtl::OUString aAuthor( "Author" ); ::rtl::OUString aKeywords( "Keywords" ); ::rtl::OUString aSubject( "Subject" ); diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index f7c5f30cbdfe..ea8fdfabf8f7 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -211,6 +211,8 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument css::uno::Reference< css::frame::XUntitledNumbers > m_xNumberedControllers; uno::Reference< rdf::XDocumentMetadataAccess> m_xDocumentMetadata; ::rtl::Reference< ::sfx2::DocumentUndoManager > m_pDocumentUndoManager; + uno::Sequence< beans::PropertyValue> m_cmisPropertiesValues; + uno::Sequence< beans::PropertyValue> m_cmisPropertiesDisplayNames; IMPL_SfxBaseModel_DataContainer( ::osl::Mutex& rMutex, SfxObjectShell* pObjectShell ) @@ -229,6 +231,8 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument , m_xNumberedControllers () , m_xDocumentMetadata () // lazy , m_pDocumentUndoManager () + , m_cmisPropertiesValues () + , m_cmisPropertiesDisplayNames () { // increase global instance counter. ++g_nInstanceCounter; @@ -2514,6 +2518,30 @@ void SAL_CALL SfxBaseModel::notifyDocumentEvent( const ::rtl::OUString&, const u throw lang::NoSupportException( ::rtl::OUString( "SfxBaseModel controlls all the sent notifications itself!" ), uno::Reference< uno::XInterface >() ); } +uno::Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getCmisPropertiesValues() + throw ( uno::RuntimeException ) +{ + return m_pData->m_cmisPropertiesValues; +} + +void SAL_CALL SfxBaseModel::setCmisPropertiesValues( const uno::Sequence< beans::PropertyValue >& _cmispropertiesvalues ) + throw ( uno::RuntimeException ) +{ + m_pData->m_cmisPropertiesValues = _cmispropertiesvalues; +} + +uno::Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getCmisPropertiesDisplayNames() + throw ( uno::RuntimeException ) +{ + return m_pData->m_cmisPropertiesDisplayNames; +} + +void SAL_CALL SfxBaseModel::setCmisPropertiesDisplayNames( const uno::Sequence< beans::PropertyValue >& _cmispropertiesdisplaynames ) + throw ( uno::RuntimeException ) +{ + m_pData->m_cmisPropertiesDisplayNames = _cmispropertiesdisplaynames; +} + //________________________________________________________________________________________________________ // SfxListener //________________________________________________________________________________________________________ diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx index afd04aebe471..fbfa83bda138 100644 --- a/ucb/source/ucp/cmis/cmis_content.cxx +++ b/ucb/source/ucp/cmis/cmis_content.cxx @@ -30,6 +30,7 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/PropertyValues.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/io/XActiveDataSink.hpp> #include <com/sun/star/io/XActiveDataStreamer.hpp> @@ -89,6 +90,123 @@ namespace return unoTime; } + + 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< rtl::OUString > aStrings( aCmisStrings.size( ) ); + rtl::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( ) ); + } + } + 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 ) + { + aLongsArr[i] = *it; + } + aValue <<= aLongs; + } + else if ( !aCmisLongs.empty( ) ) + { + aValue <<= aCmisLongs.front( ); + } + } + 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( ) ) + { + aValue <<= aCmisDoubles.front( ); + } + } + 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 ) + { + aBoolsArr[i] = *it; + } + aValue <<= aBools; + } + else if ( !aCmisBools.empty( ) ) + { + aValue <<= sal_Bool( aCmisBools.front( ) ); + } + } + 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 ) + { + aTimesArr[i] = lcl_boostToUnoTime( *it ); + } + aValue <<= aTimes; + } + else if ( !aCmisTimes.empty( ) ) + { + aValue <<= lcl_boostToUnoTime( aCmisTimes.front( ) ); + } + } + break; + } + return aValue; + } } namespace cmis @@ -374,6 +492,53 @@ namespace cmis xRow->appendVoid( rProp ); } } + else if ( rProp.Name == "CmisPropertiesValues" ) + { + try + { + libcmis::ObjectPtr object = getObject( xEnv ); + map< string, libcmis::PropertyPtr >& aProperties = object->getProperties( ); + beans::PropertyValues aCmisProperties( aProperties.size( ) ); + beans::PropertyValue* pCmisProps = aCmisProperties.getArray( ); + sal_Int32 i = 0; + for ( map< string, libcmis::PropertyPtr >::iterator it = aProperties.begin(); + it != aProperties.end( ); ++it, ++i ) + { + string name = it->first; + pCmisProps[i].Name = STD_TO_OUSTR( name ); + pCmisProps[i].Value = lcl_cmisPropertyToUno( it->second ); + } + xRow->appendObject( rProp.Name, uno::makeAny( aCmisProperties ) ); + } + catch ( const libcmis::Exception& ) + { + xRow->appendVoid( rProp ); + } + } + else if ( rProp.Name == "CmisPropertiesDisplayNames" ) + { + try + { + libcmis::ObjectPtr object = getObject( xEnv ); + map< string, libcmis::PropertyPtr >& aProperties = object->getProperties( ); + beans::PropertyValues aCmisProperties( aProperties.size( ) ); + beans::PropertyValue* pCmisProps = aCmisProperties.getArray( ); + sal_Int32 i = 0; + for ( map< string, libcmis::PropertyPtr >::iterator it = aProperties.begin(); + it != aProperties.end( ); ++it, ++i ) + { + string name = it->first; + string displayName = it->second->getPropertyType()->getDisplayName( ); + pCmisProps[i].Name = STD_TO_OUSTR( name ); + pCmisProps[i].Value = uno::makeAny( STD_TO_OUSTR( displayName ) ); + } + xRow->appendObject( rProp.Name, uno::makeAny( aCmisProperties ) ); + } + catch ( const libcmis::Exception& ) + { + xRow->appendVoid( rProp ); + } + } else SAL_INFO( "cmisucp", "Looking for unsupported property " << rProp.Name ); } @@ -798,6 +963,12 @@ namespace cmis beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), -1, getCppuType( static_cast< const rtl::OUString * >( 0 ) ), beans::PropertyAttribute::BOUND ), + beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CmisPropertiesValues" ) ), + -1, getCppuType( static_cast< const beans::PropertyValues * >( 0 ) ), + beans::PropertyAttribute::BOUND ), + beans::Property( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CmisPropertiesDisplayNames" ) ), + -1, getCppuType( static_cast< const beans::PropertyValues * >( 0 ) ), + beans::PropertyAttribute::BOUND ), }; const int nProps = SAL_N_ELEMENTS(aGenericProperties); |