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