INTEGRATION: CWS impress79 (1.139.34); FILE MERGED
2006/01/06 12:27:46 cl 1.139.34.1: #130018# make SvxShape::setPropertyValues() exception safe
This commit is contained in:
parent
089b51cec4
commit
12d70e9b56
1 changed files with 19 additions and 289 deletions
|
@ -4,9 +4,9 @@
|
|||
*
|
||||
* $RCSfile: unoshape.cxx,v $
|
||||
*
|
||||
* $Revision: 1.139 $
|
||||
* $Revision: 1.140 $
|
||||
*
|
||||
* last change: $Author: rt $ $Date: 2005-11-10 16:58:52 $
|
||||
* last change: $Author: obo $ $Date: 2006-01-20 09:30:20 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU Lesser General Public License Version 2.1.
|
||||
|
@ -181,12 +181,8 @@
|
|||
#include <outlobj.hxx>
|
||||
#endif
|
||||
|
||||
//#ifndef _COM_SUN_STAR_BEANS_TOLERANTPROPERTYSETRESULTTYPE_HPP_
|
||||
//#include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
|
||||
//#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <comphelper/scopeguard.hxx>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
using namespace ::osl;
|
||||
using namespace ::vos;
|
||||
|
@ -1060,7 +1056,7 @@ uno::Sequence< sal_Int8 > SAL_CALL SvxShape::getImplementationId()
|
|||
|
||||
Reference< uno::XInterface > SvxShape_NewInstance()
|
||||
{
|
||||
return uno::Reference< drawing::XShape >((OWeakObject*)new SvxShape(), UNO_QUERY );
|
||||
return uno::Reference< uno::XInterface >(static_cast< OWeakObject* >( new SvxShape() ) );
|
||||
}
|
||||
|
||||
// SfxListener
|
||||
|
@ -2726,6 +2722,9 @@ void SAL_CALL SvxShape::setPropertyValues( const ::com::sun::star::uno::Sequence
|
|||
|
||||
const uno::Any* pValues = aValues.getConstArray();
|
||||
|
||||
// make sure mbIsMultiPropertyCall and mpImpl->mpItemSet are
|
||||
// reseted even when an execption is thrown
|
||||
const ::comphelper::ScopeGuard aGuard( boost::bind( &SvxShape::endSetPropertyValues, this ) );
|
||||
|
||||
mbIsMultiPropertyCall = sal_True;
|
||||
|
||||
|
@ -2739,6 +2738,7 @@ void SAL_CALL SvxShape::setPropertyValues( const ::com::sun::star::uno::Sequence
|
|||
}
|
||||
catch( beans::UnknownPropertyException& e )
|
||||
{
|
||||
(void)e;
|
||||
DBG_ERROR("svx::SvxShape::setPropertyValues(), unknown property!" );
|
||||
}
|
||||
}
|
||||
|
@ -2756,20 +2756,25 @@ void SAL_CALL SvxShape::setPropertyValues( const ::com::sun::star::uno::Sequence
|
|||
}
|
||||
catch( beans::UnknownPropertyException& e )
|
||||
{
|
||||
(void)e;
|
||||
DBG_ERROR("svx::SvxShape::setPropertyValues(), unknown property!" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mbIsMultiPropertyCall = sal_False;
|
||||
if( mpImpl->mpItemSet )
|
||||
pObj->SetMergedItemSetAndBroadcast( *mpImpl->mpItemSet );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void SvxShape::endSetPropertyValues()
|
||||
{
|
||||
mbIsMultiPropertyCall = sal_False;
|
||||
if( mpImpl->mpItemSet )
|
||||
{
|
||||
//pObj->SetItemSetAndBroadcast( *mpImpl->mpItemSet );
|
||||
pObj->SetMergedItemSetAndBroadcast( *mpImpl->mpItemSet );
|
||||
|
||||
delete mpImpl->mpItemSet;
|
||||
mpImpl->mpItemSet = NULL;
|
||||
mpImpl->mpItemSet = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2832,281 +2837,6 @@ void SAL_CALL SvxShape::firePropertiesChangeEvent( const ::com::sun::star::uno::
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/*// XTolerantMultiPropertySet
|
||||
uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SvxShape::setPropertyValuesTolerant(
|
||||
const uno::Sequence< ::rtl::OUString >& aPropertyNames,
|
||||
const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues )
|
||||
throw (lang::IllegalArgumentException, uno::RuntimeException)
|
||||
{
|
||||
const sal_Int32 nCount = aPropertyNames.getLength();
|
||||
|
||||
if (nCount != aValues.getLength())
|
||||
throw lang::IllegalArgumentException();
|
||||
|
||||
const OUString* pNames = aPropertyNames.getConstArray();
|
||||
|
||||
const uno::Any* pValues = aValues.getConstArray();
|
||||
|
||||
uno::Sequence< beans::SetPropertyTolerantFailed > aRet(nCount);
|
||||
beans::SetPropertyTolerantFailed* pRet = aRet.getArray();
|
||||
sal_Int32 nFailed = 0;
|
||||
|
||||
mbIsMultiPropertyCall = sal_True;
|
||||
|
||||
if( mpImpl->mpMaster )
|
||||
{
|
||||
uno::Reference < beans::XPropertySetInfo > xInfo(getPropertySetInfo());
|
||||
for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
|
||||
{
|
||||
sal_Bool bHasByName(xInfo->hasPropertyByName(pNames[nIdx]));
|
||||
sal_Bool bReadOnly(sal_True);
|
||||
if (bHasByName)
|
||||
{
|
||||
beans::Property aProp(xInfo->getPropertyByName(pNames[nIdx]));
|
||||
bReadOnly = ((aProp.Attributes & beans::PropertyAttribute::READONLY) == beans::PropertyAttribute::READONLY);
|
||||
}
|
||||
if (bHasByName && !bReadOnly)
|
||||
{
|
||||
try
|
||||
{
|
||||
setPropertyValue( pNames[nIdx], pValues[nIdx] );
|
||||
}
|
||||
catch (lang::IllegalArgumentException)
|
||||
{
|
||||
pRet->Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
|
||||
pRet->Name = pNames[nIdx];
|
||||
++pRet;
|
||||
++nFailed;
|
||||
}
|
||||
catch (uno::Exception&)
|
||||
{
|
||||
pRet->Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
|
||||
pRet->Name = pNames[nIdx];
|
||||
++pRet;
|
||||
++nFailed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bHasByName && bReadOnly)
|
||||
pRet->Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
|
||||
else
|
||||
pRet->Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
|
||||
pRet->Name = pNames[nIdx];
|
||||
++pRet;
|
||||
++nFailed;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uno::Reference< beans::XPropertySet > xSet(queryInterface( ::getCppuType( (const uno::Reference< beans::XPropertySet >*) 0) ), uno::UNO_QUERY);
|
||||
//xSet.set(queryInterface( ::getCppuType( (const uno::Reference< beans::XPropertySet >*) 0) ), uno::UNO_QUERY);
|
||||
uno::Reference < beans::XPropertySetInfo > xInfo(xSet->getPropertySetInfo());
|
||||
|
||||
for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
|
||||
{
|
||||
sal_Bool bHasByName(xInfo->hasPropertyByName(pNames[nIdx]));
|
||||
sal_Bool bReadOnly(sal_True);
|
||||
if (bHasByName)
|
||||
{
|
||||
beans::Property aProp(xInfo->getPropertyByName(pNames[nIdx]));
|
||||
bReadOnly = ((aProp.Attributes & beans::PropertyAttribute::READONLY) == beans::PropertyAttribute::READONLY);
|
||||
}
|
||||
if (bHasByName && !bReadOnly)
|
||||
{
|
||||
try
|
||||
{
|
||||
xSet->setPropertyValue( pNames[nIdx], pValues[nIdx] );
|
||||
}
|
||||
catch (lang::IllegalArgumentException)
|
||||
{
|
||||
pRet->Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
|
||||
pRet->Name = pNames[nIdx];
|
||||
++pRet;
|
||||
++nFailed;
|
||||
}
|
||||
catch (uno::Exception&)
|
||||
{
|
||||
pRet->Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
|
||||
pRet->Name = pNames[nIdx];
|
||||
++pRet;
|
||||
++nFailed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bHasByName && bReadOnly)
|
||||
pRet->Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
|
||||
else
|
||||
pRet->Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
|
||||
pRet->Name = pNames[nIdx];
|
||||
++pRet;
|
||||
++nFailed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mbIsMultiPropertyCall = sal_False;
|
||||
|
||||
if( mpImpl->mpItemSet )
|
||||
{
|
||||
//pObj->SetItemSetAndBroadcast( *mpImpl->mpItemSet );
|
||||
// pObj->SetMergedItemSetAndBroadcast( *mpImpl->mpItemSet );
|
||||
|
||||
delete mpImpl->mpItemSet;
|
||||
mpImpl->mpItemSet = NULL;
|
||||
}
|
||||
|
||||
aRet.realloc(nFailed);
|
||||
|
||||
return aRet;
|
||||
}
|
||||
|
||||
uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL SvxShape::getPropertyValuesTolerant(
|
||||
const uno::Sequence< ::rtl::OUString >& aPropertyNames )
|
||||
throw (uno::RuntimeException)
|
||||
{
|
||||
const sal_Int32 nCount = aPropertyNames.getLength();
|
||||
const OUString* pNames = aPropertyNames.getConstArray();
|
||||
|
||||
uno::Sequence< beans::GetPropertyTolerantResult > aRet( nCount );
|
||||
beans::GetPropertyTolerantResult* pValue = aRet.getArray();;
|
||||
|
||||
if( mpImpl->mpMaster )
|
||||
{
|
||||
uno::Sequence < beans::PropertyState > aStates(getPropertyStates( aPropertyNames ));
|
||||
const beans::PropertyState *pStates = aStates.getConstArray();
|
||||
if (aStates.getLength())
|
||||
{
|
||||
for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pStates++, pNames++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
pValue->State = *pStates;
|
||||
pValue->Value = getPropertyValue( *pNames );
|
||||
pValue->Result = beans::TolerantPropertySetResultType::SUCCESS;
|
||||
}
|
||||
catch( uno::Exception& )
|
||||
{
|
||||
pValue->Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uno::Reference< beans::XPropertySet > xSet(queryInterface( ::getCppuType( (const uno::Reference< beans::XPropertySet >*) 0) ), uno::UNO_QUERY);
|
||||
uno::Reference< beans::XPropertyState > xState(xSet, uno::UNO_QUERY);
|
||||
uno::Sequence < beans::PropertyState > aStates;
|
||||
const beans::PropertyState *pStates = 0;
|
||||
if( xState.is() )
|
||||
{
|
||||
aStates = xState->getPropertyStates( aPropertyNames );
|
||||
pStates = aStates.getConstArray();
|
||||
}
|
||||
|
||||
if (aStates.getLength())
|
||||
{
|
||||
for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pStates++, pNames++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
pValue->State = *pStates;
|
||||
pValue->Value = xSet->getPropertyValue( *pNames );
|
||||
pValue->Result = beans::TolerantPropertySetResultType::SUCCESS;
|
||||
}
|
||||
catch( uno::Exception& )
|
||||
{
|
||||
pValue->Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aRet;
|
||||
}
|
||||
|
||||
uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SvxShape::getDirectPropertyValuesTolerant(
|
||||
const uno::Sequence< ::rtl::OUString >& aPropertyNames )
|
||||
throw (uno::RuntimeException)
|
||||
{
|
||||
const sal_Int32 nCount = aPropertyNames.getLength();
|
||||
const OUString* pNames = aPropertyNames.getConstArray();
|
||||
|
||||
uno::Sequence< beans::GetDirectPropertyTolerantResult > aRet( nCount );
|
||||
beans::GetDirectPropertyTolerantResult* pValue = aRet.getArray();;
|
||||
|
||||
sal_Int32 nDirectCount = 0;
|
||||
if( mpImpl->mpMaster )
|
||||
{
|
||||
uno::Sequence < beans::PropertyState > aStates(getPropertyStates( aPropertyNames ));
|
||||
if (aStates.getLength())
|
||||
{
|
||||
const beans::PropertyState *pStates = aStates.getConstArray();
|
||||
for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pStates++, pNames++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
pValue->State = *pStates;
|
||||
if (pValue->State == beans::PropertyState_DIRECT_VALUE)
|
||||
{
|
||||
pValue->Value = getPropertyValue( *pNames );
|
||||
pValue->Name = *pNames;
|
||||
pValue->Result = beans::TolerantPropertySetResultType::SUCCESS;
|
||||
pValue++;
|
||||
nDirectCount++;
|
||||
}
|
||||
}
|
||||
catch( uno::Exception& )
|
||||
{
|
||||
pValue->Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uno::Reference< beans::XPropertySet > xSet(queryInterface( ::getCppuType( (const uno::Reference< beans::XPropertySet >*) 0) ), uno::UNO_QUERY);
|
||||
uno::Reference< beans::XPropertyState > xState(xSet, uno::UNO_QUERY);
|
||||
uno::Sequence < beans::PropertyState > aStates;
|
||||
const beans::PropertyState *pStates = 0;
|
||||
if( xState.is() )
|
||||
{
|
||||
aStates = xState->getPropertyStates( aPropertyNames );
|
||||
pStates = aStates.getConstArray();
|
||||
}
|
||||
|
||||
if (aStates.getLength())
|
||||
{
|
||||
for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pStates++, pNames++ )
|
||||
{
|
||||
try
|
||||
{
|
||||
pValue->State = *pStates;
|
||||
if (pValue->State == beans::PropertyState_DIRECT_VALUE)
|
||||
{
|
||||
pValue->Value = xSet->getPropertyValue( *pNames );
|
||||
pValue->Name = *pNames;
|
||||
pValue->Result = beans::TolerantPropertySetResultType::SUCCESS;
|
||||
pValue++;
|
||||
nDirectCount++;
|
||||
}
|
||||
}
|
||||
catch( uno::Exception& )
|
||||
{
|
||||
pValue->Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
aRet.realloc(nDirectCount);
|
||||
|
||||
return aRet;
|
||||
}*/
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
uno::Any SvxShape::GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertyMap* pMap ) const
|
||||
{
|
||||
uno::Any aAny;
|
||||
|
|
Loading…
Reference in a new issue