2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-29 14:02:24 +01:00
|
|
|
/*
|
|
|
|
* 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/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2001-07-24 19:36:11 +00:00
|
|
|
|
|
|
|
#include <comphelper/ChainablePropertySet.hxx>
|
|
|
|
#include <comphelper/ChainablePropertySetInfo.hxx>
|
2013-05-14 13:15:38 +02:00
|
|
|
#include <comphelper/solarmutex.hxx>
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2014-11-14 22:52:35 +01:00
|
|
|
|
2015-02-15 20:54:22 +00:00
|
|
|
#include <memory>
|
2004-11-15 15:59:24 +00:00
|
|
|
|
2001-07-24 19:36:11 +00:00
|
|
|
using namespace ::comphelper;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
|
2013-05-14 13:15:38 +02:00
|
|
|
ChainablePropertySet::ChainablePropertySet( comphelper::ChainablePropertySetInfo* pInfo, comphelper::SolarMutex* pMutex )
|
2001-07-24 19:36:11 +00:00
|
|
|
throw()
|
2017-01-16 10:48:24 +02:00
|
|
|
: mpMutex ( pMutex )
|
2004-04-21 13:05:55 +00:00
|
|
|
, mxInfo ( pInfo )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ChainablePropertySet::~ChainablePropertySet()
|
|
|
|
throw()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// XPropertySet
|
|
|
|
Reference< XPropertySetInfo > SAL_CALL ChainablePropertySet::getPropertySetInfo( )
|
|
|
|
{
|
2017-01-16 10:48:24 +02:00
|
|
|
return mxInfo.get();
|
2001-07-24 19:36:11 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SAL_CALL ChainablePropertySet::setPropertyValue( const OUString& rPropertyName, const Any& rValue )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
2004-11-15 15:59:24 +00:00
|
|
|
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
|
2015-02-15 20:54:22 +00:00
|
|
|
std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
|
2004-11-15 15:59:24 +00:00
|
|
|
if (mpMutex)
|
2015-02-15 20:54:22 +00:00
|
|
|
xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
|
2004-11-15 15:59:24 +00:00
|
|
|
|
2017-01-16 10:48:24 +02:00
|
|
|
PropertyInfoHash::const_iterator aIter = mxInfo->maMap.find ( rPropertyName );
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2017-01-16 10:48:24 +02:00
|
|
|
if( aIter == mxInfo->maMap.end())
|
2008-12-01 12:31:27 +00:00
|
|
|
throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
|
2001-07-24 19:36:11 +00:00
|
|
|
|
|
|
|
_preSetValues();
|
|
|
|
_setSingleValue( *((*aIter).second), rValue );
|
|
|
|
_postSetValues();
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
Any SAL_CALL ChainablePropertySet::getPropertyValue( const OUString& rPropertyName )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
2004-11-15 15:59:24 +00:00
|
|
|
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
|
2015-02-15 20:54:22 +00:00
|
|
|
std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
|
2004-11-15 15:59:24 +00:00
|
|
|
if (mpMutex)
|
2015-02-15 20:54:22 +00:00
|
|
|
xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2017-01-16 10:48:24 +02:00
|
|
|
PropertyInfoHash::const_iterator aIter = mxInfo->maMap.find ( rPropertyName );
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2017-01-16 10:48:24 +02:00
|
|
|
if( aIter == mxInfo->maMap.end())
|
2008-12-01 12:31:27 +00:00
|
|
|
throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
|
2001-07-24 19:36:11 +00:00
|
|
|
|
|
|
|
Any aAny;
|
|
|
|
_preGetValues ();
|
|
|
|
_getSingleValue( *((*aIter).second), aAny );
|
|
|
|
_postGetValues ();
|
|
|
|
|
|
|
|
return aAny;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SAL_CALL ChainablePropertySet::addPropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
|
|
|
// todo
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SAL_CALL ChainablePropertySet::removePropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
|
|
|
// todo
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SAL_CALL ChainablePropertySet::addVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
|
|
|
// todo
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SAL_CALL ChainablePropertySet::removeVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
|
|
|
// todo
|
|
|
|
}
|
|
|
|
|
|
|
|
// XMultiPropertySet
|
2014-06-13 11:18:47 +01:00
|
|
|
void SAL_CALL ChainablePropertySet::setPropertyValues(const Sequence< OUString >& rPropertyNames, const Sequence< Any >& rValues)
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
2004-11-15 15:59:24 +00:00
|
|
|
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
|
2015-02-15 20:54:22 +00:00
|
|
|
std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
|
2004-11-15 15:59:24 +00:00
|
|
|
if (mpMutex)
|
2015-02-15 20:54:22 +00:00
|
|
|
xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
|
2004-11-15 15:59:24 +00:00
|
|
|
|
2014-06-13 11:18:47 +01:00
|
|
|
const sal_Int32 nCount = rPropertyNames.getLength();
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2014-06-13 11:18:47 +01:00
|
|
|
if( nCount != rValues.getLength() )
|
2001-07-24 19:36:11 +00:00
|
|
|
throw IllegalArgumentException();
|
|
|
|
|
2020-04-18 11:35:04 +02:00
|
|
|
if( !nCount )
|
|
|
|
return;
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2020-04-18 11:35:04 +02:00
|
|
|
_preSetValues();
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2020-04-18 11:35:04 +02:00
|
|
|
const Any * pAny = rValues.getConstArray();
|
|
|
|
const OUString * pString = rPropertyNames.getConstArray();
|
|
|
|
PropertyInfoHash::const_iterator aEnd = mxInfo->maMap.end(), aIter;
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2020-04-18 11:35:04 +02:00
|
|
|
for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny )
|
|
|
|
{
|
|
|
|
aIter = mxInfo->maMap.find ( *pString );
|
|
|
|
if ( aIter == aEnd )
|
|
|
|
throw RuntimeException( *pString, static_cast< XPropertySet* >( this ) );
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2020-04-18 11:35:04 +02:00
|
|
|
_setSingleValue ( *((*aIter).second), *pAny );
|
2001-07-24 19:36:11 +00:00
|
|
|
}
|
2020-04-18 11:35:04 +02:00
|
|
|
|
|
|
|
_postSetValues();
|
2001-07-24 19:36:11 +00:00
|
|
|
}
|
|
|
|
|
2014-06-13 11:18:47 +01:00
|
|
|
Sequence< Any > SAL_CALL ChainablePropertySet::getPropertyValues(const Sequence< OUString >& rPropertyNames)
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
2004-11-15 15:59:24 +00:00
|
|
|
// acquire mutex in c-tor and releases it in the d-tor (exception safe!).
|
2015-02-15 20:54:22 +00:00
|
|
|
std::unique_ptr< osl::Guard< comphelper::SolarMutex > > xMutexGuard;
|
2004-11-15 15:59:24 +00:00
|
|
|
if (mpMutex)
|
2015-02-15 20:54:22 +00:00
|
|
|
xMutexGuard.reset( new osl::Guard< comphelper::SolarMutex >(mpMutex) );
|
2004-11-15 15:59:24 +00:00
|
|
|
|
2014-06-13 11:18:47 +01:00
|
|
|
const sal_Int32 nCount = rPropertyNames.getLength();
|
2001-07-24 19:36:11 +00:00
|
|
|
|
|
|
|
Sequence < Any > aValues ( nCount );
|
|
|
|
|
|
|
|
if( nCount )
|
|
|
|
{
|
|
|
|
_preGetValues();
|
|
|
|
|
|
|
|
Any * pAny = aValues.getArray();
|
2014-06-13 11:18:47 +01:00
|
|
|
const OUString * pString = rPropertyNames.getConstArray();
|
2017-01-16 10:48:24 +02:00
|
|
|
PropertyInfoHash::const_iterator aEnd = mxInfo->maMap.end(), aIter;
|
2001-07-24 19:36:11 +00:00
|
|
|
|
|
|
|
for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pAny )
|
|
|
|
{
|
2017-01-16 10:48:24 +02:00
|
|
|
aIter = mxInfo->maMap.find ( *pString );
|
2001-07-24 19:36:11 +00:00
|
|
|
if ( aIter == aEnd )
|
2014-06-13 11:18:47 +01:00
|
|
|
throw RuntimeException( *pString, static_cast< XPropertySet* >( this ) );
|
2001-07-24 19:36:11 +00:00
|
|
|
|
|
|
|
_getSingleValue ( *((*aIter).second), *pAny );
|
|
|
|
}
|
|
|
|
|
|
|
|
_postGetValues();
|
|
|
|
}
|
|
|
|
return aValues;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SAL_CALL ChainablePropertySet::addPropertiesChangeListener( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
|
|
|
// todo
|
|
|
|
}
|
|
|
|
|
2006-06-19 21:50:35 +00:00
|
|
|
void SAL_CALL ChainablePropertySet::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
|
|
|
// todo
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SAL_CALL ChainablePropertySet::firePropertiesChangeEvent( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
|
|
|
// todo
|
|
|
|
}
|
|
|
|
|
|
|
|
// XPropertyState
|
2013-04-07 12:06:47 +02:00
|
|
|
PropertyState SAL_CALL ChainablePropertySet::getPropertyState( const OUString& PropertyName )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
2017-01-16 10:48:24 +02:00
|
|
|
PropertyInfoHash::const_iterator aIter = mxInfo->maMap.find( PropertyName );
|
|
|
|
if( aIter == mxInfo->maMap.end())
|
2008-12-01 12:31:27 +00:00
|
|
|
throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) );
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2017-06-20 09:26:05 +02:00
|
|
|
return PropertyState_AMBIGUOUS_VALUE;
|
2001-07-24 19:36:11 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
Sequence< PropertyState > SAL_CALL ChainablePropertySet::getPropertyStates( const Sequence< OUString >& rPropertyNames )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
|
|
|
const sal_Int32 nCount = rPropertyNames.getLength();
|
|
|
|
|
|
|
|
Sequence< PropertyState > aStates( nCount );
|
|
|
|
if( nCount )
|
|
|
|
{
|
|
|
|
PropertyState * pState = aStates.getArray();
|
|
|
|
const OUString * pString = rPropertyNames.getConstArray();
|
2017-01-16 10:48:24 +02:00
|
|
|
PropertyInfoHash::const_iterator aEnd = mxInfo->maMap.end(), aIter;
|
2001-07-24 19:36:11 +00:00
|
|
|
|
|
|
|
for ( sal_Int32 i = 0; i < nCount; ++i, ++pString, ++pState )
|
|
|
|
{
|
2017-01-16 10:48:24 +02:00
|
|
|
aIter = mxInfo->maMap.find ( *pString );
|
2001-07-24 19:36:11 +00:00
|
|
|
if ( aIter == aEnd )
|
2008-12-01 12:31:27 +00:00
|
|
|
throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) );
|
2001-07-24 19:36:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return aStates;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void SAL_CALL ChainablePropertySet::setPropertyToDefault( const OUString& rPropertyName )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
2017-01-16 10:48:24 +02:00
|
|
|
PropertyInfoHash::const_iterator aIter = mxInfo->maMap.find ( rPropertyName );
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2017-01-16 10:48:24 +02:00
|
|
|
if( aIter == mxInfo->maMap.end())
|
2008-12-01 12:31:27 +00:00
|
|
|
throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
|
2001-07-24 19:36:11 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
Any SAL_CALL ChainablePropertySet::getPropertyDefault( const OUString& rPropertyName )
|
2001-07-24 19:36:11 +00:00
|
|
|
{
|
2017-01-16 10:48:24 +02:00
|
|
|
PropertyInfoHash::const_iterator aIter = mxInfo->maMap.find ( rPropertyName );
|
2001-07-24 19:36:11 +00:00
|
|
|
|
2017-01-16 10:48:24 +02:00
|
|
|
if( aIter == mxInfo->maMap.end())
|
2008-12-01 12:31:27 +00:00
|
|
|
throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) );
|
2017-04-21 11:35:25 +02:00
|
|
|
return Any();
|
2001-07-24 19:36:11 +00:00
|
|
|
}
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|