Index: toolkit/inc/toolkit/awt/vclxwindows.hxx
===================================================================
RCS file: /cvs/gsl/toolkit/inc/toolkit/awt/vclxwindows.hxx,v
retrieving revision 1.36.114.1
diff -u -p -u -r1.36.114.1 vclxwindows.hxx
--- toolkit/inc/toolkit/awt/vclxwindows.hxx	13 Jul 2007 17:43:51 -0000	1.36.114.1
+++ toolkit/inc/toolkit/awt/vclxwindows.hxx	25 Jul 2007 16:21:13 -0000
@@ -142,6 +142,9 @@
 #ifndef _COM_SUN_STAR_AWT_XNUMERICFIELD_HPP_
 #include <com/sun/star/awt/XNumericField.hpp>
 #endif
+#ifndef _COM_SUN_STAR_AWT_XMetricFIELD_HPP_
+#include <com/sun/star/awt/XMetricField.hpp>
+#endif
 #ifndef _COM_SUN_STAR_AWT_XBUTTON_HPP_
 #include <com/sun/star/awt/XButton.hpp>
 #endif
@@ -1024,6 +1027,58 @@ public:
 };
 
 //	----------------------------------------------------
+//	class VCLXMetricField
+//	----------------------------------------------------
+class MetricFormatter;
+class MetricField;
+class VCLXMetricField :	public ::com::sun::star::awt::XMetricField,
+                        public VCLXFormattedSpinField
+{
+    MetricFormatter *GetMetricFormatter() throw(::com::sun::star::uno::RuntimeException);
+    MetricField     *GetMetricField() throw(::com::sun::star::uno::RuntimeException);
+    void CallListeners();
+public:
+    VCLXMetricField();
+    ~VCLXMetricField();
+
+	// ::com::sun::star::uno::XInterface
+    ::com::sun::star::uno::Any					SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+	void										SAL_CALL acquire() throw()	{ OWeakObject::acquire(); }
+	void										SAL_CALL release() throw()	{ OWeakObject::release(); }
+
+    // ::com::sun::star::lang::XTypeProvider
+	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >	SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
+	::com::sun::star::uno::Sequence< sal_Int8 >						SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
+
+	// ::com::sun::star::awt::XMetricField
+    virtual void SAL_CALL setValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Int64 SAL_CALL getValue( ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Int64 SAL_CALL getCorrectedValue( ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setMin( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Int64 SAL_CALL getMin( ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setMax( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Int64 SAL_CALL getMax( ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setFirst( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Int64 SAL_CALL getFirst( ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setLast( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Int64 SAL_CALL getLast( ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setSpinSize( ::sal_Int64 Value ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Int64 SAL_CALL getSpinSize(  ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setDecimalDigits( ::sal_Int16 nDigits ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Int16 SAL_CALL getDecimalDigits(  ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL setStrictFormat( ::sal_Bool bStrict ) throw (::com::sun::star::uno::RuntimeException);
+    virtual ::sal_Bool SAL_CALL isStrictFormat(  ) throw (::com::sun::star::uno::RuntimeException);
+
+	// ::com::sun::star::awt::VclWindowPeer
+    void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException);
+    ::com::sun::star::uno::Any SAL_CALL getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException);
+
+    static void     ImplGetPropertyIds( std::list< sal_uInt16 > &aIds );
+    virtual void    GetPropertyIds( std::list< sal_uInt16 > &aIds ) { return ImplGetPropertyIds( aIds ); }
+};
+
+//	----------------------------------------------------
 //	class VCLXCurrencyField
 //	----------------------------------------------------
 class VCLXCurrencyField :	public ::com::sun::star::awt::XCurrencyField,
Index: toolkit/source/awt/vclxtoolkit.cxx
===================================================================
RCS file: /cvs/gsl/toolkit/source/awt/vclxtoolkit.cxx,v
retrieving revision 1.56
diff -u -p -u -r1.56 vclxtoolkit.cxx
--- toolkit/source/awt/vclxtoolkit.cxx	6 Jul 2007 14:26:42 -0000	1.56
+++ toolkit/source/awt/vclxtoolkit.cxx	25 Jul 2007 16:21:14 -0000
@@ -862,7 +862,8 @@ Window*	VCLXToolkit::ImplCreateWindow( V
 			break;
 			case WINDOW_METRICFIELD:
 				pNewWindow = new MetricField( pParent, nWinBits );
-				*ppNewComp = new VCLXSpinField;
+				*ppNewComp = new VCLXMetricField;
+				((VCLXFormattedSpinField*)*ppNewComp)->SetFormatter( (FormatterBase*)(MetricField*)pNewWindow );
 			break;
 			case WINDOW_DIALOG:
 			case WINDOW_MODALDIALOG:
Index: toolkit/source/awt/vclxwindows.cxx
===================================================================
RCS file: /cvs/gsl/toolkit/source/awt/vclxwindows.cxx,v
retrieving revision 1.63.8.1
diff -u -p -u -r1.63.8.1 vclxwindows.cxx
--- toolkit/source/awt/vclxwindows.cxx	13 Jul 2007 17:43:52 -0000	1.63.8.1
+++ toolkit/source/awt/vclxwindows.cxx	25 Jul 2007 16:21:15 -0000
@@ -4735,6 +4735,252 @@ void VCLXNumericField::setProperty( cons
 
 
 //	----------------------------------------------------
+//	class VCLXMetricField
+//	----------------------------------------------------
+
+void VCLXMetricField::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
+{
+    PushPropertyIds( rIds,
+                     BASEPROPERTY_BACKGROUNDCOLOR,
+                     BASEPROPERTY_BORDER,
+                     BASEPROPERTY_BORDERCOLOR,
+                     BASEPROPERTY_DECIMALACCURACY,
+                     BASEPROPERTY_DEFAULTCONTROL,
+                     BASEPROPERTY_ENABLED,
+                     BASEPROPERTY_FONTDESCRIPTOR,
+                     BASEPROPERTY_HELPTEXT,
+                     BASEPROPERTY_HELPURL,
+                     BASEPROPERTY_NUMSHOWTHOUSANDSEP,
+                     BASEPROPERTY_PRINTABLE,
+                     BASEPROPERTY_READONLY,
+                     BASEPROPERTY_REPEAT,
+                     BASEPROPERTY_REPEAT_DELAY,
+                     BASEPROPERTY_SPIN,
+                     BASEPROPERTY_STRICTFORMAT,
+                     BASEPROPERTY_TABSTOP,
+                     BASEPROPERTY_ENFORCE_FORMAT,
+                     BASEPROPERTY_HIDEINACTIVESELECTION,
+                     BASEPROPERTY_UNIT,
+                     BASEPROPERTY_CUSTOMUNITTEXT,
+                     0);
+    VCLXFormattedSpinField::ImplGetPropertyIds( rIds );
+}
+
+VCLXMetricField::VCLXMetricField()
+{
+}
+
+VCLXMetricField::~VCLXMetricField()
+{
+}
+
+MetricFormatter *VCLXMetricField::GetMetricFormatter() throw(::com::sun::star::uno::RuntimeException)
+{
+    MetricFormatter *pFormatter = (MetricFormatter *) GetFormatter();
+    if (!pFormatter)
+        throw ::com::sun::star::uno::RuntimeException();
+    return pFormatter;
+}
+
+MetricField *VCLXMetricField::GetMetricField() throw(::com::sun::star::uno::RuntimeException)
+{
+    MetricField *pField = (MetricField *) GetWindow();
+    if (!pField)
+        throw ::com::sun::star::uno::RuntimeException();
+    return pField;
+}
+
+// ::com::sun::star::uno::XInterface
+::com::sun::star::uno::Any VCLXMetricField::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
+{
+	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
+                                                              SAL_STATIC_CAST( ::com::sun::star::awt::XMetricField*, this ) );
+	return (aRet.hasValue() ? aRet : VCLXFormattedSpinField::queryInterface( rType ));
+}
+
+// ::com::sun::star::lang::XTypeProvider
+IMPL_XTYPEPROVIDER_START( VCLXMetricField )
+	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMetricField>* ) NULL ),
+	VCLXFormattedSpinField::getTypes()
+IMPL_XTYPEPROVIDER_END
+
+// FIXME: later ...
+#define MetricUnitUnoToVcl(a) ((FieldUnit)(a))
+
+#define METRIC_MAP_PAIR(method,parent) \
+    sal_Int64 VCLXMetricField::get##method( sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) \
+    { \
+    	::vos::OGuard aGuard( GetMutex() ); \
+        return GetMetric##parent()->Get##method( MetricUnitUnoToVcl( nUnit ) ); \
+    } \
+    void VCLXMetricField::set##method( sal_Int64 nValue, sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException) \
+    { \
+    	::vos::OGuard aGuard( GetMutex() ); \
+        GetMetric##parent()->Set##method( nValue, MetricUnitUnoToVcl( nUnit ) ); \
+    }
+
+METRIC_MAP_PAIR(Min, Formatter)
+METRIC_MAP_PAIR(Max, Formatter)
+METRIC_MAP_PAIR(First, Field)
+METRIC_MAP_PAIR(Last,  Field)
+
+#undef METRIC_MAP_SET
+#undef METRIC_MAP_GET
+
+::sal_Int64 VCLXMetricField::getValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException)
+{
+    ::vos::OGuard aGuard( GetMutex() );
+    return GetMetricFormatter()->GetValue( MetricUnitUnoToVcl( nUnit ) );
+}
+
+::sal_Int64 VCLXMetricField::getCorrectedValue( ::sal_Int16 nUnit ) throw (::com::sun::star::uno::RuntimeException)
+{
+    ::vos::OGuard aGuard( GetMutex() );
+    return GetMetricFormatter()->GetCorrectedValue( MetricUnitUnoToVcl( nUnit ) );
+}
+
+// FIXME: acute cut/paste evilness - move this to the parent Edit class ?
+void VCLXMetricField::CallListeners()
+{
+    // #107218# Call same listeners like VCL would do after user interaction
+    Edit* pEdit = (Edit*)GetWindow();
+    if ( pEdit )
+    {
+        SetSynthesizingVCLEvent( sal_True );
+        pEdit->SetModifyFlag();
+        pEdit->Modify();
+        SetSynthesizingVCLEvent( sal_False );
+	}
+}
+
+void VCLXMetricField::setValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException)
+{
+	::vos::OGuard aGuard( GetMutex() );
+    GetMetricFormatter()->SetValue( Value, MetricUnitUnoToVcl( Unit ) );
+    CallListeners();
+}
+
+void VCLXMetricField::setUserValue( ::sal_Int64 Value, ::sal_Int16 Unit ) throw (::com::sun::star::uno::RuntimeException)
+{
+	::vos::OGuard aGuard( GetMutex() );
+    GetMetricFormatter()->SetUserValue( Value, MetricUnitUnoToVcl( Unit ) );
+    CallListeners();
+}
+
+void VCLXMetricField::setStrictFormat( sal_Bool bStrict ) throw(::com::sun::star::uno::RuntimeException)
+{
+	VCLXFormattedSpinField::setStrictFormat( bStrict );
+}
+
+sal_Bool VCLXMetricField::isStrictFormat() throw(::com::sun::star::uno::RuntimeException)
+{
+	return VCLXFormattedSpinField::isStrictFormat();
+}
+
+void VCLXMetricField::setSpinSize( sal_Int64 Value ) throw(::com::sun::star::uno::RuntimeException)
+{
+	::vos::OGuard aGuard( GetMutex() );
+    GetMetricField()->SetSpinSize( Value );
+}
+
+sal_Int64 VCLXMetricField::getSpinSize() throw(::com::sun::star::uno::RuntimeException)
+{
+	::vos::OGuard aGuard( GetMutex() );
+    return GetMetricField()->GetSpinSize();
+}
+
+void VCLXMetricField::setDecimalDigits( sal_Int16 Value ) throw(::com::sun::star::uno::RuntimeException)
+{
+	::vos::OGuard aGuard( GetMutex() );
+    GetMetricFormatter()->SetDecimalDigits( Value );
+}
+
+sal_Int16 VCLXMetricField::getDecimalDigits() throw(::com::sun::star::uno::RuntimeException)
+{
+	::vos::OGuard aGuard( GetMutex() );
+
+	NumericFormatter* pNumericFormatter = (NumericFormatter*) GetFormatter();
+	return pNumericFormatter ? pNumericFormatter->GetDecimalDigits() : 0;
+}
+
+void VCLXMetricField::setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value) throw(::com::sun::star::uno::RuntimeException)
+{
+	::vos::OGuard aGuard( GetMutex() );
+
+	if ( GetWindow() )
+	{
+		sal_uInt16 nPropType = GetPropertyId( PropertyName );
+		switch ( nPropType )
+		{
+			case BASEPROPERTY_DECIMALACCURACY:
+			{
+				sal_Int16 n;
+				if ( Value >>= n )
+ 					setDecimalDigits( n );
+                break;
+			}
+			case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
+			{
+				sal_Bool b;
+				if ( Value >>= b )
+ 					((NumericField*)GetWindow())->SetUseThousandSep( b );
+			}
+			break;
+            case BASEPROPERTY_UNIT:
+            {
+                sal_uInt16 nVal;
+                if ( Value >>= nVal )
+                    ((MetricField*)GetWindow())->SetUnit( (FieldUnit) nVal );
+                break;
+            }
+            case BASEPROPERTY_CUSTOMUNITTEXT:
+            {
+                rtl::OUString aStr;
+                if ( Value >>= aStr )
+                    ((MetricField*)GetWindow())->SetCustomUnitText( aStr );
+                break;
+            }
+			default:
+			{
+				VCLXFormattedSpinField::setProperty( PropertyName, Value );
+                break;
+			}
+		}
+	}
+}
+
+::com::sun::star::uno::Any VCLXMetricField::getProperty( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::uno::RuntimeException)
+{
+	::vos::OGuard aGuard( GetMutex() );
+
+	::com::sun::star::uno::Any aProp;
+	FormatterBase* pFormatter = GetFormatter();
+	if ( pFormatter )
+	{
+		sal_uInt16 nPropType = GetPropertyId( PropertyName );
+		switch ( nPropType )
+		{
+			case BASEPROPERTY_NUMSHOWTHOUSANDSEP:
+			    aProp <<= (sal_Bool) ((NumericField*)GetWindow())->IsUseThousandSep();
+                break;
+            case BASEPROPERTY_UNIT:
+			    aProp <<= (sal_uInt16) ((MetricField*)GetWindow())->GetUnit();
+                break;
+            case BASEPROPERTY_CUSTOMUNITTEXT:
+			    aProp <<= rtl::OUString (((MetricField*)GetWindow())->GetCustomUnitText());
+                break;
+			default:
+			{
+				aProp <<= VCLXFormattedSpinField::getProperty( PropertyName );
+                break;
+			}
+		}
+	}
+	return aProp;
+}
+
+
+//	----------------------------------------------------
 //	class VCLXCurrencyField
 //	----------------------------------------------------
 
Index: toolkit/source/helper/property.cxx
===================================================================
RCS file: /cvs/gsl/toolkit/source/helper/property.cxx,v
retrieving revision 1.37
diff -u -p -u -r1.37 property.cxx
--- toolkit/source/helper/property.cxx	6 Jul 2007 14:28:22 -0000	1.37
+++ toolkit/source/helper/property.cxx	25 Jul 2007 16:21:15 -0000
@@ -178,6 +178,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( 
             DECL_DEP_PROP_3 ( "BorderColor",            BORDERCOLOR,        sal_Int32,          BOUND, MAYBEDEFAULT, MAYBEVOID ),
             DECL_PROP_2     ( "Closeable",              CLOSEABLE,          bool,               BOUND, MAYBEDEFAULT ),
             DECL_PROP_2     ( "CurrencySymbol",         CURRENCYSYMBOL,     ::rtl::OUString,    BOUND, MAYBEDEFAULT ),
+            DECL_PROP_2     ( "CustomUnitText",         CUSTOMUNITTEXT,     ::rtl::OUString,    BOUND, MAYBEDEFAULT ),
             DECL_DEP_PROP_3 ( "Date",                   DATE,               sal_Int32,          BOUND, MAYBEDEFAULT, MAYBEVOID ),
             DECL_PROP_2     ( "DateFormat",             EXTDATEFORMAT,      sal_Int16,          BOUND, MAYBEDEFAULT ),
             DECL_PROP_2     ( "DateMax",                DATEMAX,            sal_Int32,          BOUND, MAYBEDEFAULT ),
@@ -289,6 +290,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( 
             DECL_PROP_2     ( "Toggle",                 TOGGLE,                 bool,           BOUND, MAYBEDEFAULT ),
             DECL_PROP_3     ( "TreatAsNumber",          TREATASNUMBER,          bool,           BOUND, MAYBEDEFAULT,TRANSIENT ),
             DECL_PROP_2     ( "TriState",               TRISTATE,               bool,           BOUND, MAYBEDEFAULT ),
+            DECL_PROP_2     ( "Unit",                   UNIT,                   sal_uInt16,     BOUND, MAYBEDEFAULT ),
             DECL_PROP_2     ( "VScroll",                VSCROLL,                bool,           BOUND, MAYBEDEFAULT ),
             DECL_DEP_PROP_3 ( "Value",                  VALUE_DOUBLE,           double,         BOUND, MAYBEDEFAULT, MAYBEVOID ),
             DECL_PROP_2     ( "ValueMax",               VALUEMAX_DOUBLE,        double,         BOUND, MAYBEDEFAULT ),
Index: toolkit/inc/toolkit/helper/property.hxx
===================================================================
RCS file: /cvs/gsl/toolkit/inc/toolkit/helper/property.hxx,v
retrieving revision 1.31
diff -u -p -r1.31 property.hxx
--- toolkit/inc/toolkit/helper/property.hxx	3 Aug 2007 09:54:28 -0000	1.31
+++ toolkit/inc/toolkit/helper/property.hxx	6 Nov 2007 17:16:16 -0000
@@ -194,6 +194,9 @@ namespace rtl {
 #define BASEPROPERTY_TREE_INVOKESSTOPNODEEDITING	131
 #define BASEPROPERTY_TREE_END						131
 
+#define BASEPROPERTY_UNIT                  BASEPROPERTY_TREE_END + 1  // ::awt::FieldUnit
+#define BASEPROPERTY_CUSTOMUNITTEXT        BASEPROPERTY_TREE_END + 2  // ::rtl::OUString
+
 // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen.
 #define BASEPROPERTY_FONTDESCRIPTORPART_START			1000
 #define BASEPROPERTY_FONTDESCRIPTORPART_NAME			1000	// ::rtl::OUString, not bound
