diff options
author | Mathias Bauer <mba@openoffice.org> | 2010-01-22 16:42:24 +0100 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2010-01-22 16:42:24 +0100 |
commit | d0d27202a22a88947249be238b23c5a82af94691 (patch) | |
tree | e112f1c89436e6c4f577cfd92db86427f615b810 /editeng | |
parent | d5d854cc42815ff0bbe0347be4e28c8896048b8d (diff) |
#i107450#: wrong treatment of metric items in Writer
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/inc/editeng/unoipset.hxx | 5 | ||||
-rw-r--r-- | editeng/source/uno/unoipset.cxx | 44 |
2 files changed, 33 insertions, 16 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); |