diff options
-rw-r--r-- | editeng/inc/editeng/unoipset.hxx | 5 | ||||
-rw-r--r-- | editeng/source/uno/unoipset.cxx | 44 | ||||
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 57 |
3 files changed, 38 insertions, 68 deletions
diff --git a/editeng/inc/editeng/unoipset.hxx b/editeng/inc/editeng/unoipset.hxx index 57bc4c3183ad..a3ed027e83b7 100644 --- a/editeng/inc/editeng/unoipset.hxx +++ b/editeng/inc/editeng/unoipset.hxx @@ -57,8 +57,8 @@ public: ~SvxItemPropertySet(); // Methoden, die direkt mit dem ItemSet arbeiten - ::com::sun::star::uno::Any getPropertyValue( const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet, bool bSearchInParent ) const; - void setPropertyValue( const SfxItemPropertySimpleEntry* pMap, const ::com::sun::star::uno::Any& rVal, SfxItemSet& rSet ) const; + ::com::sun::star::uno::Any getPropertyValue( const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet, bool bSearchInParent=true, bool bDontConvertNegativeValues=false ) const; + void setPropertyValue( const SfxItemPropertySimpleEntry* pMap, const ::com::sun::star::uno::Any& rVal, SfxItemSet& rSet, bool bDontConvertNegativeValues=false ) const; // Methoden, die stattdessen Any benutzen ::com::sun::star::uno::Any getPropertyValue( const SfxItemPropertySimpleEntry* pMap ) const; @@ -70,7 +70,6 @@ public: com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > getPropertySetInfo() const; const SfxItemPropertyMapEntry* getPropertyMapEntries() const {return _pMap;} - //void setPropertyMap( const SfxItemPropertyMapEntry *pMap ) { _pMap = pMap; } const SfxItemPropertyMap* getPropertyMap()const { return &m_aPropertyMap;} const SfxItemPropertySimpleEntry* getPropertyMapEntry(const ::rtl::OUString &rName) const; diff --git a/editeng/source/uno/unoipset.cxx b/editeng/source/uno/unoipset.cxx index b6a5876a25af..fd3a8d674264 100644 --- a/editeng/source/uno/unoipset.cxx +++ b/editeng/source/uno/unoipset.cxx @@ -114,41 +114,51 @@ void SvxItemPropertySet::AddUsrAnyForID(const uno::Any& rAny, sal_uInt16 nWID) pCombiList->Insert(pNew); } +sal_Bool SvxUnoCheckForPositiveValue( const uno::Any& rVal ) +{ + sal_Bool bConvert = sal_True; // the default is that all metric items must be converted + sal_Int32 nValue = 0; + if( rVal >>= nValue ) + bConvert = (nValue > 0); + return bConvert; +} + + //---------------------------------------------------------------------- -uno::Any SvxItemPropertySet::getPropertyValue( const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet, bool bSearchInParent ) const +uno::Any SvxItemPropertySet::getPropertyValue( const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet, bool bSearchInParent, bool bDontConvertNegativeValues ) const { uno::Any aVal; if(!pMap || !pMap->nWID) return aVal; - // item holen const SfxPoolItem* pItem = 0; SfxItemPool* pPool = rSet.GetPool(); - rSet.GetItemState( pMap->nWID, bSearchInParent, &pItem ); - if( NULL == pItem && pPool ) - { pItem = &(pPool->GetDefaultItem( pMap->nWID )); - } const SfxMapUnit eMapUnit = pPool ? pPool->GetMetric((USHORT)pMap->nWID) : SFX_MAPUNIT_100TH_MM; - BYTE nMemberId = pMap->nMemberId & (~SFX_METRIC_ITEM); if( eMapUnit == SFX_MAPUNIT_100TH_MM ) nMemberId &= (~CONVERT_TWIPS); - // item-Wert als UnoAny zurueckgeben if(pItem) { pItem->QueryValue( aVal, nMemberId ); - - // convert typeless SfxEnumItem to enum type - if ( !(pMap->nMemberId & SFX_METRIC_ITEM) && pMap->pType->getTypeClass() == uno::TypeClass_ENUM && aVal.getValueType() == ::getCppuType((const sal_Int32*)0) ) + if( pMap->nMemberId & SFX_METRIC_ITEM ) { + if( eMapUnit != SFX_MAPUNIT_100TH_MM ) + { + if ( !bDontConvertNegativeValues || SvxUnoCheckForPositiveValue( aVal ) ) + SvxUnoConvertToMM( eMapUnit, aVal ); + } + } + else if ( pMap->pType->getTypeClass() == uno::TypeClass_ENUM && + aVal.getValueType() == ::getCppuType((const sal_Int32*)0) ) + { + // convert typeless SfxEnumItem to enum type sal_Int32 nEnum; aVal >>= nEnum; - aVal.setValue( &nEnum, *pMap->pType ); } } @@ -161,7 +171,7 @@ uno::Any SvxItemPropertySet::getPropertyValue( const SfxItemPropertySimpleEntry* } //---------------------------------------------------------------------- -void SvxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry* pMap, const uno::Any& rVal, SfxItemSet& rSet ) const +void SvxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry* pMap, const uno::Any& rVal, SfxItemSet& rSet, bool bDontConvertNegativeValues ) const { if(!pMap || !pMap->nWID) return; @@ -190,6 +200,14 @@ void SvxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry* pMa uno::Any aValue( rVal ); const SfxMapUnit eMapUnit = pPool ? pPool->GetMetric((USHORT)pMap->nWID) : SFX_MAPUNIT_100TH_MM; + + // check for needed metric translation + if( (pMap->nMemberId & SFX_METRIC_ITEM) && eMapUnit != SFX_MAPUNIT_100TH_MM ) + { + if ( !bDontConvertNegativeValues || SvxUnoCheckForPositiveValue( aValue ) ) + SvxUnoConvertFromMM( eMapUnit, aValue ); + } + pNewItem = pItem->Clone(); BYTE nMemberId = pMap->nMemberId & (~SFX_METRIC_ITEM); diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index d68eb053ede1..18c2faee22cf 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -4551,49 +4551,14 @@ SdrObject* SdrObject::getSdrObjectFromXShape( const ::com::sun::star::uno::Refer return pSvxShape ? pSvxShape->GetSdrObject() : 0; } -/** this function checks if a SFX_METRIC_ITEM realy needs to be converted. - This check is for items that store either metric values if theire positiv - or percentage if theire negativ. -*/ -sal_Bool SvxUnoCheckForConversion( const SfxItemSet&, sal_Int32 nWID, const uno::Any& rVal ) -{ - sal_Bool bConvert = sal_True; // the default is that all metric items must be converted - - switch( nWID ) - { - case XATTR_FILLBMP_SIZEX: - case XATTR_FILLBMP_SIZEY: - { - sal_Int32 nValue = 0; - if( rVal >>= nValue ) - bConvert = nValue > 0; - break; - } - } - - // the default is to always - return bConvert; -} - uno::Any SvxItemPropertySet_getPropertyValue( const SvxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet ) { if(!pMap || !pMap->nWID) return uno::Any(); - uno::Any aVal = rPropSet.getPropertyValue( pMap, rSet, (pMap->nWID != SDRATTR_XMLATTRIBUTES) ); - if( pMap->nMemberId & SFX_METRIC_ITEM ) - { - // check for needed metric translation - SfxItemPool* pPool = rSet.GetPool(); - const SfxMapUnit eMapUnit = pPool ? pPool->GetMetric((USHORT)pMap->nWID) : SFX_MAPUNIT_100TH_MM; - if( (pMap->nMemberId & SFX_METRIC_ITEM) && (eMapUnit != SFX_MAPUNIT_100TH_MM) ) - { - if( SvxUnoCheckForConversion( rSet, pMap->nWID, aVal ) ) - SvxUnoConvertToMM( eMapUnit, aVal ); - } - } - - return aVal; + // Check is for items that store either metric values if thei are positiv or percentage if thei are negativ. + bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY ); + return rPropSet.getPropertyValue( pMap, rSet, (pMap->nWID != SDRATTR_XMLATTRIBUTES), bDontConvertNegativeValues ); } void SvxItemPropertySet_setPropertyValue( const SvxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry* pMap, const uno::Any& rVal, SfxItemSet& rSet ) @@ -4601,18 +4566,6 @@ void SvxItemPropertySet_setPropertyValue( const SvxItemPropertySet& rPropSet, co if(!pMap || !pMap->nWID) return; - uno::Any aValue( rVal ); - if( pMap->nMemberId & SFX_METRIC_ITEM ) - { - // check for needed metric translation - SfxItemPool* pPool = rSet.GetPool(); - const SfxMapUnit eMapUnit = pPool ? pPool->GetMetric((USHORT)pMap->nWID) : SFX_MAPUNIT_100TH_MM; - if( (pMap->nMemberId & SFX_METRIC_ITEM) && eMapUnit != SFX_MAPUNIT_100TH_MM ) - { - if( SvxUnoCheckForConversion( rSet, pMap->nWID, aValue ) ) - SvxUnoConvertFromMM( eMapUnit, aValue ); - } - } - - rPropSet.setPropertyValue( pMap, aValue, rSet ); + bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY ); + rPropSet.setPropertyValue( pMap, rVal, rSet, bDontConvertNegativeValues ); } |