1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_editeng.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 31*cdf0e10cSrcweir #include <svl/eitem.hxx> 32*cdf0e10cSrcweir #include <tools/list.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <hash_map> 35*cdf0e10cSrcweir #include <vector> 36*cdf0e10cSrcweir #include <svl/itemprop.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <editeng/unoipset.hxx> 39*cdf0e10cSrcweir #include <editeng/editids.hrc> 40*cdf0e10cSrcweir #include <editeng/editeng.hxx> 41*cdf0e10cSrcweir #include <svl/itempool.hxx> 42*cdf0e10cSrcweir #include <algorithm> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir using namespace ::com::sun::star; 45*cdf0e10cSrcweir using namespace ::rtl; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir //---------------------------------------------------------------------- 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir struct SfxItemPropertyMapEntryHash 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir size_t operator()(const SfxItemPropertyMapEntry* pMap) const { return (size_t)pMap; } 52*cdf0e10cSrcweir }; 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir //---------------------------------------------------------------------- 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir struct SvxIDPropertyCombine 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir sal_uInt16 nWID; 59*cdf0e10cSrcweir uno::Any aAny; 60*cdf0e10cSrcweir }; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir DECLARE_LIST( SvxIDPropertyCombineList, SvxIDPropertyCombine * ) 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir SvxItemPropertySet::SvxItemPropertySet( const SfxItemPropertyMapEntry* pMap, SfxItemPool& rItemPool, sal_Bool bConvertTwips ) 65*cdf0e10cSrcweir : m_aPropertyMap( pMap ), 66*cdf0e10cSrcweir _pMap(pMap), mbConvertTwips(bConvertTwips), mrItemPool( rItemPool ) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir pCombiList = NULL; 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir //---------------------------------------------------------------------- 72*cdf0e10cSrcweir SvxItemPropertySet::~SvxItemPropertySet() 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir ClearAllUsrAny(); 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir //---------------------------------------------------------------------- 78*cdf0e10cSrcweir uno::Any* SvxItemPropertySet::GetUsrAnyForID(sal_uInt16 nWID) const 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir if(pCombiList && pCombiList->Count()) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir SvxIDPropertyCombine* pActual = pCombiList->First(); 83*cdf0e10cSrcweir while(pActual) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir if(pActual->nWID == nWID) 86*cdf0e10cSrcweir return &pActual->aAny; 87*cdf0e10cSrcweir pActual = pCombiList->Next(); 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir return NULL; 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir //---------------------------------------------------------------------- 95*cdf0e10cSrcweir void SvxItemPropertySet::AddUsrAnyForID(const uno::Any& rAny, sal_uInt16 nWID) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir if(!pCombiList) 98*cdf0e10cSrcweir pCombiList = new SvxIDPropertyCombineList(); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir SvxIDPropertyCombine* pNew = new SvxIDPropertyCombine; 101*cdf0e10cSrcweir pNew->nWID = nWID; 102*cdf0e10cSrcweir pNew->aAny = rAny; 103*cdf0e10cSrcweir pCombiList->Insert(pNew); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir //---------------------------------------------------------------------- 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir void SvxItemPropertySet::ClearAllUsrAny() 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir if(pCombiList) 111*cdf0e10cSrcweir delete pCombiList; 112*cdf0e10cSrcweir pCombiList = NULL; 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir //---------------------------------------------------------------------- 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir sal_Bool SvxUnoCheckForPositiveValue( const uno::Any& rVal ) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir sal_Bool bConvert = sal_True; // the default is that all metric items must be converted 120*cdf0e10cSrcweir sal_Int32 nValue = 0; 121*cdf0e10cSrcweir if( rVal >>= nValue ) 122*cdf0e10cSrcweir bConvert = (nValue > 0); 123*cdf0e10cSrcweir return bConvert; 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir //---------------------------------------------------------------------- 128*cdf0e10cSrcweir uno::Any SvxItemPropertySet::getPropertyValue( const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet, bool bSearchInParent, bool bDontConvertNegativeValues ) const 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir uno::Any aVal; 131*cdf0e10cSrcweir if(!pMap || !pMap->nWID) 132*cdf0e10cSrcweir return aVal; 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir const SfxPoolItem* pItem = 0; 135*cdf0e10cSrcweir SfxItemPool* pPool = rSet.GetPool(); 136*cdf0e10cSrcweir rSet.GetItemState( pMap->nWID, bSearchInParent, &pItem ); 137*cdf0e10cSrcweir if( NULL == pItem && pPool ) 138*cdf0e10cSrcweir pItem = &(pPool->GetDefaultItem( pMap->nWID )); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir const SfxMapUnit eMapUnit = pPool ? pPool->GetMetric((sal_uInt16)pMap->nWID) : SFX_MAPUNIT_100TH_MM; 141*cdf0e10cSrcweir sal_uInt8 nMemberId = pMap->nMemberId & (~SFX_METRIC_ITEM); 142*cdf0e10cSrcweir if( eMapUnit == SFX_MAPUNIT_100TH_MM ) 143*cdf0e10cSrcweir nMemberId &= (~CONVERT_TWIPS); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir if(pItem) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir pItem->QueryValue( aVal, nMemberId ); 148*cdf0e10cSrcweir if( pMap->nMemberId & SFX_METRIC_ITEM ) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir if( eMapUnit != SFX_MAPUNIT_100TH_MM ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir if ( !bDontConvertNegativeValues || SvxUnoCheckForPositiveValue( aVal ) ) 153*cdf0e10cSrcweir SvxUnoConvertToMM( eMapUnit, aVal ); 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir else if ( pMap->pType->getTypeClass() == uno::TypeClass_ENUM && 157*cdf0e10cSrcweir aVal.getValueType() == ::getCppuType((const sal_Int32*)0) ) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir // convert typeless SfxEnumItem to enum type 160*cdf0e10cSrcweir sal_Int32 nEnum; 161*cdf0e10cSrcweir aVal >>= nEnum; 162*cdf0e10cSrcweir aVal.setValue( &nEnum, *pMap->pType ); 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir else 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir DBG_ERROR( "No SfxPoolItem found for property!" ); 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir return aVal; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir //---------------------------------------------------------------------- 174*cdf0e10cSrcweir void SvxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry* pMap, const uno::Any& rVal, SfxItemSet& rSet, bool bDontConvertNegativeValues ) const 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir if(!pMap || !pMap->nWID) 177*cdf0e10cSrcweir return; 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir // item holen 180*cdf0e10cSrcweir const SfxPoolItem* pItem = 0; 181*cdf0e10cSrcweir SfxPoolItem *pNewItem = 0; 182*cdf0e10cSrcweir SfxItemState eState = rSet.GetItemState( pMap->nWID, sal_True, &pItem ); 183*cdf0e10cSrcweir SfxItemPool* pPool = rSet.GetPool(); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir // UnoAny in item-Wert stecken 186*cdf0e10cSrcweir if(eState < SFX_ITEM_DEFAULT || pItem == NULL) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir if( pPool == NULL ) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir DBG_ERROR( "No default item and no pool?" ); 191*cdf0e10cSrcweir return; 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir pItem = &pPool->GetDefaultItem( pMap->nWID ); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir DBG_ASSERT( pItem, "Got no default for item!" ); 198*cdf0e10cSrcweir if( pItem ) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir uno::Any aValue( rVal ); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir const SfxMapUnit eMapUnit = pPool ? pPool->GetMetric((sal_uInt16)pMap->nWID) : SFX_MAPUNIT_100TH_MM; 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir // check for needed metric translation 205*cdf0e10cSrcweir if( (pMap->nMemberId & SFX_METRIC_ITEM) && eMapUnit != SFX_MAPUNIT_100TH_MM ) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir if ( !bDontConvertNegativeValues || SvxUnoCheckForPositiveValue( aValue ) ) 208*cdf0e10cSrcweir SvxUnoConvertFromMM( eMapUnit, aValue ); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir pNewItem = pItem->Clone(); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir sal_uInt8 nMemberId = pMap->nMemberId & (~SFX_METRIC_ITEM); 214*cdf0e10cSrcweir if( eMapUnit == SFX_MAPUNIT_100TH_MM ) 215*cdf0e10cSrcweir nMemberId &= (~CONVERT_TWIPS); 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir if( pNewItem->PutValue( aValue, nMemberId ) ) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir // neues item in itemset setzen 220*cdf0e10cSrcweir rSet.Put( *pNewItem, pMap->nWID ); 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir delete pNewItem; 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir //---------------------------------------------------------------------- 227*cdf0e10cSrcweir uno::Any SvxItemPropertySet::getPropertyValue( const SfxItemPropertySimpleEntry* pMap ) const 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir // Schon ein Wert eingetragen? Dann schnell fertig 230*cdf0e10cSrcweir uno::Any* pUsrAny = GetUsrAnyForID(pMap->nWID); 231*cdf0e10cSrcweir if(pUsrAny) 232*cdf0e10cSrcweir return *pUsrAny; 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir // Noch kein UsrAny gemerkt, generiere Default-Eintrag und gib 235*cdf0e10cSrcweir // diesen zurueck 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir const SfxMapUnit eMapUnit = mrItemPool.GetMetric((sal_uInt16)pMap->nWID); 238*cdf0e10cSrcweir sal_uInt8 nMemberId = pMap->nMemberId & (~SFX_METRIC_ITEM); 239*cdf0e10cSrcweir if( eMapUnit == SFX_MAPUNIT_100TH_MM ) 240*cdf0e10cSrcweir nMemberId &= (~CONVERT_TWIPS); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir uno::Any aVal; 243*cdf0e10cSrcweir SfxItemSet aSet( mrItemPool, pMap->nWID, pMap->nWID); 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir if( (pMap->nWID < OWN_ATTR_VALUE_START) && (pMap->nWID > OWN_ATTR_VALUE_END ) ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir // Default aus ItemPool holen 248*cdf0e10cSrcweir if(mrItemPool.IsWhich(pMap->nWID)) 249*cdf0e10cSrcweir aSet.Put(mrItemPool.GetDefaultItem(pMap->nWID)); 250*cdf0e10cSrcweir } 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir if(aSet.Count()) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir const SfxPoolItem* pItem = NULL; 255*cdf0e10cSrcweir SfxItemState eState = aSet.GetItemState( pMap->nWID, sal_True, &pItem ); 256*cdf0e10cSrcweir if(eState >= SFX_ITEM_DEFAULT && pItem) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir pItem->QueryValue( aVal, nMemberId ); 259*cdf0e10cSrcweir ((SvxItemPropertySet*)this)->AddUsrAnyForID(aVal, pMap->nWID); 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir if( pMap->nMemberId & SFX_METRIC_ITEM ) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir // check for needed metric translation 266*cdf0e10cSrcweir if(pMap->nMemberId & SFX_METRIC_ITEM && eMapUnit != SFX_MAPUNIT_100TH_MM) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir SvxUnoConvertToMM( eMapUnit, aVal ); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir if ( pMap->pType->getTypeClass() == uno::TypeClass_ENUM && 273*cdf0e10cSrcweir aVal.getValueType() == ::getCppuType((const sal_Int32*)0) ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir sal_Int32 nEnum; 276*cdf0e10cSrcweir aVal >>= nEnum; 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir aVal.setValue( &nEnum, *pMap->pType ); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir return aVal; 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir //---------------------------------------------------------------------- 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir void SvxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry* pMap, const uno::Any& rVal ) const 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir uno::Any* pUsrAny = GetUsrAnyForID(pMap->nWID); 289*cdf0e10cSrcweir if(!pUsrAny) 290*cdf0e10cSrcweir ((SvxItemPropertySet*)this)->AddUsrAnyForID(rVal, pMap->nWID); 291*cdf0e10cSrcweir else 292*cdf0e10cSrcweir *pUsrAny = rVal; 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir //---------------------------------------------------------------------- 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir const SfxItemPropertySimpleEntry* SvxItemPropertySet::getPropertyMapEntry(const OUString &rName) const 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir return m_aPropertyMap.getByName( rName ); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir //---------------------------------------------------------------------- 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SvxItemPropertySet::getPropertySetInfo() const 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir if( !m_xInfo.is() ) 307*cdf0e10cSrcweir m_xInfo = new SfxItemPropertySetInfo( &m_aPropertyMap ); 308*cdf0e10cSrcweir return m_xInfo; 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir //---------------------------------------------------------------------- 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir #ifndef TWIPS_TO_MM 314*cdf0e10cSrcweir #define TWIPS_TO_MM(val) ((val * 127 + 36) / 72) 315*cdf0e10cSrcweir #endif 316*cdf0e10cSrcweir #ifndef MM_TO_TWIPS 317*cdf0e10cSrcweir #define MM_TO_TWIPS(val) ((val * 72 + 63) / 127) 318*cdf0e10cSrcweir #endif 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir /** converts the given any with a metric to 100th/mm if needed */ 321*cdf0e10cSrcweir void SvxUnoConvertToMM( const SfxMapUnit eSourceMapUnit, uno::Any & rMetric ) throw() 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir // map the metric of the itempool to 100th mm 324*cdf0e10cSrcweir switch(eSourceMapUnit) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir case SFX_MAPUNIT_TWIP : 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir switch( rMetric.getValueTypeClass() ) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir case uno::TypeClass_BYTE: 331*cdf0e10cSrcweir rMetric <<= (sal_Int8)(TWIPS_TO_MM(*(sal_Int8*)rMetric.getValue())); 332*cdf0e10cSrcweir break; 333*cdf0e10cSrcweir case uno::TypeClass_SHORT: 334*cdf0e10cSrcweir rMetric <<= (sal_Int16)(TWIPS_TO_MM(*(sal_Int16*)rMetric.getValue())); 335*cdf0e10cSrcweir break; 336*cdf0e10cSrcweir case uno::TypeClass_UNSIGNED_SHORT: 337*cdf0e10cSrcweir rMetric <<= (sal_uInt16)(TWIPS_TO_MM(*(sal_uInt16*)rMetric.getValue())); 338*cdf0e10cSrcweir break; 339*cdf0e10cSrcweir case uno::TypeClass_LONG: 340*cdf0e10cSrcweir rMetric <<= (sal_Int32)(TWIPS_TO_MM(*(sal_Int32*)rMetric.getValue())); 341*cdf0e10cSrcweir break; 342*cdf0e10cSrcweir case uno::TypeClass_UNSIGNED_LONG: 343*cdf0e10cSrcweir rMetric <<= (sal_uInt32)(TWIPS_TO_MM(*(sal_uInt32*)rMetric.getValue())); 344*cdf0e10cSrcweir break; 345*cdf0e10cSrcweir default: 346*cdf0e10cSrcweir DBG_ERROR("AW: Missing unit translation to 100th mm!"); 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir break; 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir default: 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir DBG_ERROR("AW: Missing unit translation to 100th mm!"); 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir //---------------------------------------------------------------------- 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir /** converts the given any with a metric from 100th/mm to the given metric if needed */ 360*cdf0e10cSrcweir void SvxUnoConvertFromMM( const SfxMapUnit eDestinationMapUnit, uno::Any & rMetric ) throw() 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir switch(eDestinationMapUnit) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir case SFX_MAPUNIT_TWIP : 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir switch( rMetric.getValueTypeClass() ) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir case uno::TypeClass_BYTE: 369*cdf0e10cSrcweir rMetric <<= (sal_Int8)(MM_TO_TWIPS(*(sal_Int8*)rMetric.getValue())); 370*cdf0e10cSrcweir break; 371*cdf0e10cSrcweir case uno::TypeClass_SHORT: 372*cdf0e10cSrcweir rMetric <<= (sal_Int16)(MM_TO_TWIPS(*(sal_Int16*)rMetric.getValue())); 373*cdf0e10cSrcweir break; 374*cdf0e10cSrcweir case uno::TypeClass_UNSIGNED_SHORT: 375*cdf0e10cSrcweir rMetric <<= (sal_uInt16)(MM_TO_TWIPS(*(sal_uInt16*)rMetric.getValue())); 376*cdf0e10cSrcweir break; 377*cdf0e10cSrcweir case uno::TypeClass_LONG: 378*cdf0e10cSrcweir rMetric <<= (sal_Int32)(MM_TO_TWIPS(*(sal_Int32*)rMetric.getValue())); 379*cdf0e10cSrcweir break; 380*cdf0e10cSrcweir case uno::TypeClass_UNSIGNED_LONG: 381*cdf0e10cSrcweir rMetric <<= (sal_uInt32)(MM_TO_TWIPS(*(sal_uInt32*)rMetric.getValue())); 382*cdf0e10cSrcweir break; 383*cdf0e10cSrcweir default: 384*cdf0e10cSrcweir DBG_ERROR("AW: Missing unit translation to 100th mm!"); 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir break; 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir default: 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir DBG_ERROR("AW: Missing unit translation to PoolMetrics!"); 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir 395