1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2a97ec55SAndrew Rist  * distributed with this work for additional information
6*2a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2a97ec55SAndrew Rist  *
11*2a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2a97ec55SAndrew Rist  *
13*2a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist  * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2a97ec55SAndrew Rist  * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist  * under the License.
19*2a97ec55SAndrew Rist  *
20*2a97ec55SAndrew Rist  *************************************************************/
21*2a97ec55SAndrew Rist 
22*2a97ec55SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir #include "usercontrol.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir /** === begin UNO includes === **/
29cdf0e10cSrcweir #include <com/sun/star/inspection/PropertyControlType.hpp>
30cdf0e10cSrcweir #include <com/sun/star/inspection/PropertyControlType.hpp>
31cdf0e10cSrcweir /** === end UNO includes === **/
32cdf0e10cSrcweir #include <svl/numuno.hxx>
33cdf0e10cSrcweir #include <rtl/math.hxx>
34cdf0e10cSrcweir #include <tools/debug.hxx>
35cdf0e10cSrcweir #include <svl/zformat.hxx>
36cdf0e10cSrcweir #include <connectivity/dbconversion.hxx>
37cdf0e10cSrcweir #include <com/sun/star/util/Time.hpp>
38cdf0e10cSrcweir #include "modulepcr.hxx"
39cdf0e10cSrcweir #include "propresid.hrc"
40cdf0e10cSrcweir 
41cdf0e10cSrcweir //............................................................................
42cdf0e10cSrcweir namespace pcr
43cdf0e10cSrcweir {
44cdf0e10cSrcweir //............................................................................
45cdf0e10cSrcweir 
46cdf0e10cSrcweir     /** === begin UNO using === **/
47cdf0e10cSrcweir     using ::com::sun::star::uno::Any;
48cdf0e10cSrcweir     using ::com::sun::star::uno::Type;
49cdf0e10cSrcweir     using ::com::sun::star::beans::IllegalTypeException;
50cdf0e10cSrcweir     using ::com::sun::star::uno::RuntimeException;
51cdf0e10cSrcweir     /** === end UNO using === **/
52cdf0e10cSrcweir     namespace PropertyControlType = ::com::sun::star::inspection::PropertyControlType;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	//==================================================================
55cdf0e10cSrcweir 	// NumberFormatSampleField
56cdf0e10cSrcweir 	//==================================================================
57cdf0e10cSrcweir 	//------------------------------------------------------------------
PreNotify(NotifyEvent & rNEvt)58cdf0e10cSrcweir 	long NumberFormatSampleField::PreNotify( NotifyEvent& rNEvt )
59cdf0e10cSrcweir 	{
60cdf0e10cSrcweir 		// want to handle two keys myself : Del/Backspace should empty the window (setting my prop to "standard" this way)
61cdf0e10cSrcweir 		if (EVENT_KEYINPUT == rNEvt.GetType())
62cdf0e10cSrcweir 		{
63cdf0e10cSrcweir 			sal_uInt16 nKey = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 			if ((KEY_DELETE == nKey) || (KEY_BACKSPACE == nKey))
66cdf0e10cSrcweir 			{
67cdf0e10cSrcweir 				SetText( String() );
68cdf0e10cSrcweir                 if ( m_pHelper )
69cdf0e10cSrcweir 				    m_pHelper->ModifiedHdl( this );
70cdf0e10cSrcweir 				return 1;
71cdf0e10cSrcweir 			}
72cdf0e10cSrcweir 		}
73cdf0e10cSrcweir 
74cdf0e10cSrcweir         return BaseClass::PreNotify( rNEvt );
75cdf0e10cSrcweir 	}
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	//------------------------------------------------------------------
SetFormatSupplier(const SvNumberFormatsSupplierObj * pSupplier)78cdf0e10cSrcweir 	void NumberFormatSampleField::SetFormatSupplier( const SvNumberFormatsSupplierObj* pSupplier )
79cdf0e10cSrcweir 	{
80cdf0e10cSrcweir 		if ( pSupplier )
81cdf0e10cSrcweir 		{
82cdf0e10cSrcweir 			TreatAsNumber( sal_True );
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 			SvNumberFormatter* pFormatter = pSupplier->GetNumberFormatter();
85cdf0e10cSrcweir 			SetFormatter( pFormatter, sal_True );
86cdf0e10cSrcweir 			SetValue( 1234.56789 );
87cdf0e10cSrcweir 		}
88cdf0e10cSrcweir 		else
89cdf0e10cSrcweir 		{
90cdf0e10cSrcweir 			TreatAsNumber( sal_False );
91cdf0e10cSrcweir 			SetFormatter( NULL, sal_True );
92cdf0e10cSrcweir 			SetText( String() );
93cdf0e10cSrcweir 		}
94cdf0e10cSrcweir 	}
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	//==================================================================
97cdf0e10cSrcweir 	// OFormatSampleControl
98cdf0e10cSrcweir 	//==================================================================
99cdf0e10cSrcweir 	//------------------------------------------------------------------
OFormatSampleControl(Window * pParent,WinBits nWinStyle)100cdf0e10cSrcweir 	OFormatSampleControl::OFormatSampleControl( Window* pParent, WinBits nWinStyle )
101cdf0e10cSrcweir         :OFormatSampleControl_Base( PropertyControlType::Unknown, pParent, nWinStyle )
102cdf0e10cSrcweir 	{
103cdf0e10cSrcweir 	}
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	//------------------------------------------------------------------
setValue(const Any & _rValue)106cdf0e10cSrcweir 	void SAL_CALL OFormatSampleControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
107cdf0e10cSrcweir 	{
108cdf0e10cSrcweir         sal_Int32 nFormatKey = 0;
109cdf0e10cSrcweir         if ( _rValue >>= nFormatKey )
110cdf0e10cSrcweir 		{
111cdf0e10cSrcweir 			// else set the new format key, the text will be reformatted
112cdf0e10cSrcweir             getTypedControlWindow()->SetFormatKey( nFormatKey );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir             SvNumberFormatter* pNF = getTypedControlWindow()->GetFormatter();
115cdf0e10cSrcweir             const SvNumberformat* pEntry = pNF->GetEntry( nFormatKey );
116cdf0e10cSrcweir             OSL_ENSURE( pEntry, "OFormatSampleControl::setValue: invalid format entry!" );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir             const bool bIsTextFormat = ( pEntry && pEntry->IsTextFormat() );
119cdf0e10cSrcweir             if ( bIsTextFormat )
120cdf0e10cSrcweir                 getTypedControlWindow()->SetText( String( PcrRes( RID_STR_TEXT_FORMAT ) ) );
121cdf0e10cSrcweir             else
122cdf0e10cSrcweir                 getTypedControlWindow()->SetValue( pEntry ? getPreviewValue( *pEntry ) : 1234.56789 );
123cdf0e10cSrcweir 		}
124cdf0e10cSrcweir         else
125cdf0e10cSrcweir 			getTypedControlWindow()->SetText( String() );
126cdf0e10cSrcweir 	}
127cdf0e10cSrcweir     //------------------------------------------------------------------
getPreviewValue(const SvNumberformat & i_rEntry)128cdf0e10cSrcweir     double OFormatSampleControl::getPreviewValue( const SvNumberformat& i_rEntry )
129cdf0e10cSrcweir     {
130cdf0e10cSrcweir         double nValue = 1234.56789;
131cdf0e10cSrcweir 		switch ( i_rEntry.GetType() & ~NUMBERFORMAT_DEFINED )
132cdf0e10cSrcweir 		{
133cdf0e10cSrcweir 			case NUMBERFORMAT_DATE:
134cdf0e10cSrcweir                 {
135cdf0e10cSrcweir                     Date aCurrentDate;
136cdf0e10cSrcweir 	                static ::com::sun::star::util::Date STANDARD_DB_DATE(30,12,1899);
137cdf0e10cSrcweir 	                nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(static_cast<sal_Int32>(aCurrentDate.GetDate())),STANDARD_DB_DATE);
138cdf0e10cSrcweir                 }
139cdf0e10cSrcweir                 break;
140cdf0e10cSrcweir 			case NUMBERFORMAT_TIME:
141cdf0e10cSrcweir             case NUMBERFORMAT_DATETIME:
142cdf0e10cSrcweir                 {
143cdf0e10cSrcweir                     Time aCurrentTime;
144cdf0e10cSrcweir                     nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(aCurrentTime.GetTime()));
145cdf0e10cSrcweir                 }
146cdf0e10cSrcweir 				break;
147cdf0e10cSrcweir 			default:
148cdf0e10cSrcweir 				break;
149cdf0e10cSrcweir 		}
150cdf0e10cSrcweir         return nValue;
151cdf0e10cSrcweir     }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     //------------------------------------------------------------------
getPreviewValue(SvNumberFormatter * _pNF,sal_Int32 _nFormatKey)154cdf0e10cSrcweir     double OFormatSampleControl::getPreviewValue(SvNumberFormatter* _pNF,sal_Int32 _nFormatKey)
155cdf0e10cSrcweir     {
156cdf0e10cSrcweir         const SvNumberformat* pEntry = _pNF->GetEntry(_nFormatKey);
157cdf0e10cSrcweir         DBG_ASSERT( pEntry, "OFormattedNumericControl::SetFormatDescription: invalid format key!" );
158cdf0e10cSrcweir         double nValue = 1234.56789;
159cdf0e10cSrcweir 		if ( pEntry )
160cdf0e10cSrcweir             nValue = getPreviewValue( *pEntry );
161cdf0e10cSrcweir         return nValue;
162cdf0e10cSrcweir     }
163cdf0e10cSrcweir 	//------------------------------------------------------------------
getValue()164cdf0e10cSrcweir 	Any SAL_CALL OFormatSampleControl::getValue() throw (RuntimeException)
165cdf0e10cSrcweir 	{
166cdf0e10cSrcweir         Any aPropValue;
167cdf0e10cSrcweir 		if ( getTypedControlWindow()->GetText().Len() )
168cdf0e10cSrcweir             aPropValue <<= (sal_Int32)getTypedControlWindow()->GetFormatKey();
169cdf0e10cSrcweir         return aPropValue;
170cdf0e10cSrcweir 	}
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	//------------------------------------------------------------------
getValueType()173cdf0e10cSrcweir     Type SAL_CALL OFormatSampleControl::getValueType() throw (RuntimeException)
174cdf0e10cSrcweir     {
175cdf0e10cSrcweir         return ::getCppuType( static_cast< sal_Int32* >( NULL ) );
176cdf0e10cSrcweir     }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	//==================================================================
179cdf0e10cSrcweir 	// class OFormattedNumericControl
180cdf0e10cSrcweir 	//==================================================================
181cdf0e10cSrcweir 	DBG_NAME(OFormattedNumericControl);
182cdf0e10cSrcweir 	//------------------------------------------------------------------
OFormattedNumericControl(Window * pParent,WinBits nWinStyle)183cdf0e10cSrcweir 	OFormattedNumericControl::OFormattedNumericControl( Window* pParent, WinBits nWinStyle )
184cdf0e10cSrcweir         :OFormattedNumericControl_Base( PropertyControlType::Unknown, pParent, nWinStyle )
185cdf0e10cSrcweir 	{
186cdf0e10cSrcweir 		DBG_CTOR(OFormattedNumericControl,NULL);
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 		getTypedControlWindow()->TreatAsNumber(sal_True);
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 		m_nLastDecimalDigits = getTypedControlWindow()->GetDecimalDigits();
191cdf0e10cSrcweir 	}
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 	//------------------------------------------------------------------
~OFormattedNumericControl()194cdf0e10cSrcweir 	OFormattedNumericControl::~OFormattedNumericControl()
195cdf0e10cSrcweir 	{
196cdf0e10cSrcweir 		DBG_DTOR(OFormattedNumericControl,NULL);
197cdf0e10cSrcweir 	}
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 	//------------------------------------------------------------------
setValue(const Any & _rValue)200cdf0e10cSrcweir 	void SAL_CALL OFormattedNumericControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
201cdf0e10cSrcweir 	{
202cdf0e10cSrcweir         double nValue( 0 );
203cdf0e10cSrcweir         if ( _rValue >>= nValue )
204cdf0e10cSrcweir 			getTypedControlWindow()->SetValue( nValue );
205cdf0e10cSrcweir 		else
206cdf0e10cSrcweir 			getTypedControlWindow()->SetText(String());
207cdf0e10cSrcweir 	}
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 	//------------------------------------------------------------------
getValue()210cdf0e10cSrcweir 	Any SAL_CALL OFormattedNumericControl::getValue() throw (RuntimeException)
211cdf0e10cSrcweir 	{
212cdf0e10cSrcweir         Any aPropValue;
213cdf0e10cSrcweir 		if ( getTypedControlWindow()->GetText().Len() )
214cdf0e10cSrcweir             aPropValue <<= (double)getTypedControlWindow()->GetValue();
215cdf0e10cSrcweir         return aPropValue;
216cdf0e10cSrcweir 	}
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 	//------------------------------------------------------------------
getValueType()219cdf0e10cSrcweir     Type SAL_CALL OFormattedNumericControl::getValueType() throw (RuntimeException)
220cdf0e10cSrcweir     {
221cdf0e10cSrcweir         return ::getCppuType( static_cast< double* >( NULL ) );
222cdf0e10cSrcweir     }
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 	//------------------------------------------------------------------
SetFormatDescription(const FormatDescription & rDesc)225cdf0e10cSrcweir 	void OFormattedNumericControl::SetFormatDescription(const FormatDescription& rDesc)
226cdf0e10cSrcweir 	{
227cdf0e10cSrcweir 		sal_Bool bFallback = sal_True;
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 		if (rDesc.pSupplier)
230cdf0e10cSrcweir 		{
231cdf0e10cSrcweir 			getTypedControlWindow()->TreatAsNumber(sal_True);
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 			SvNumberFormatter* pFormatter = rDesc.pSupplier->GetNumberFormatter();
234cdf0e10cSrcweir 			if (pFormatter != getTypedControlWindow()->GetFormatter())
235cdf0e10cSrcweir 				getTypedControlWindow()->SetFormatter(pFormatter, sal_True);
236cdf0e10cSrcweir 			getTypedControlWindow()->SetFormatKey(rDesc.nKey);
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 			const SvNumberformat* pEntry = getTypedControlWindow()->GetFormatter()->GetEntry(getTypedControlWindow()->GetFormatKey());
239cdf0e10cSrcweir 			DBG_ASSERT( pEntry, "OFormattedNumericControl::SetFormatDescription: invalid format key!" );
240cdf0e10cSrcweir 			if ( pEntry )
241cdf0e10cSrcweir 			{
242cdf0e10cSrcweir 				switch (pEntry->GetType() & ~NUMBERFORMAT_DEFINED)
243cdf0e10cSrcweir 				{
244cdf0e10cSrcweir 					case NUMBERFORMAT_NUMBER:
245cdf0e10cSrcweir 					case NUMBERFORMAT_CURRENCY:
246cdf0e10cSrcweir 					case NUMBERFORMAT_SCIENTIFIC:
247cdf0e10cSrcweir 					case NUMBERFORMAT_FRACTION:
248cdf0e10cSrcweir 					case NUMBERFORMAT_PERCENT:
249cdf0e10cSrcweir 						m_nLastDecimalDigits = getTypedControlWindow()->GetDecimalDigits();
250cdf0e10cSrcweir 						break;
251cdf0e10cSrcweir 					case NUMBERFORMAT_DATETIME:
252cdf0e10cSrcweir 					case NUMBERFORMAT_DATE:
253cdf0e10cSrcweir 					case NUMBERFORMAT_TIME:
254cdf0e10cSrcweir 						m_nLastDecimalDigits = 7;
255cdf0e10cSrcweir 						break;
256cdf0e10cSrcweir 					default:
257cdf0e10cSrcweir 						m_nLastDecimalDigits = 0;
258cdf0e10cSrcweir 						break;
259cdf0e10cSrcweir 				}
260cdf0e10cSrcweir 				bFallback = sal_False;
261cdf0e10cSrcweir 			}
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 		}
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 		if ( bFallback )
266cdf0e10cSrcweir 		{
267cdf0e10cSrcweir 			getTypedControlWindow()->TreatAsNumber(sal_False);
268cdf0e10cSrcweir 			getTypedControlWindow()->SetFormatter(NULL, sal_True);
269cdf0e10cSrcweir 			getTypedControlWindow()->SetText(String());
270cdf0e10cSrcweir 			m_nLastDecimalDigits = 0;
271cdf0e10cSrcweir 		}
272cdf0e10cSrcweir 	}
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 	//========================================================================
275cdf0e10cSrcweir 	//= OFileUrlControl
276cdf0e10cSrcweir 	//========================================================================
277cdf0e10cSrcweir 	//------------------------------------------------------------------
OFileUrlControl(Window * pParent,WinBits nWinStyle)278cdf0e10cSrcweir     OFileUrlControl::OFileUrlControl( Window* pParent, WinBits nWinStyle )
279cdf0e10cSrcweir         :OFileUrlControl_Base( PropertyControlType::Unknown, pParent, nWinStyle | WB_DROPDOWN )
280cdf0e10cSrcweir     {
281cdf0e10cSrcweir         getTypedControlWindow()->SetDropDownLineCount( 10 );
282cdf0e10cSrcweir         getTypedControlWindow()->SetPlaceHolder( String( PcrRes( RID_EMBED_IMAGE_PLACEHOLDER ) ) ) ;
283cdf0e10cSrcweir     }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 	//------------------------------------------------------------------
~OFileUrlControl()286cdf0e10cSrcweir     OFileUrlControl::~OFileUrlControl()
287cdf0e10cSrcweir     {
288cdf0e10cSrcweir     }
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 	//------------------------------------------------------------------
setValue(const Any & _rValue)291cdf0e10cSrcweir 	void SAL_CALL OFileUrlControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
292cdf0e10cSrcweir     {
293cdf0e10cSrcweir         ::rtl::OUString sURL;
294cdf0e10cSrcweir         if ( ( _rValue >>= sURL ) )
295cdf0e10cSrcweir         {
296cdf0e10cSrcweir             if ( sURL.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:"  ) ) ) == 0  )
297cdf0e10cSrcweir                 getTypedControlWindow()->DisplayURL( getTypedControlWindow()->GetPlaceHolder() );
298cdf0e10cSrcweir             else
299cdf0e10cSrcweir                 getTypedControlWindow()->DisplayURL( sURL );
300cdf0e10cSrcweir         }
301cdf0e10cSrcweir         else
302cdf0e10cSrcweir             getTypedControlWindow()->SetText( String() );
303cdf0e10cSrcweir     }
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 	//------------------------------------------------------------------
getValue()306cdf0e10cSrcweir 	Any SAL_CALL OFileUrlControl::getValue() throw (RuntimeException)
307cdf0e10cSrcweir     {
308cdf0e10cSrcweir         Any aPropValue;
309cdf0e10cSrcweir         if ( getTypedControlWindow()->GetText().Len() )
310cdf0e10cSrcweir             	aPropValue <<= (::rtl::OUString)getTypedControlWindow()->GetURL();
311cdf0e10cSrcweir         return aPropValue;
312cdf0e10cSrcweir     }
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 	//------------------------------------------------------------------
getValueType()315cdf0e10cSrcweir     Type SAL_CALL OFileUrlControl::getValueType() throw (RuntimeException)
316cdf0e10cSrcweir     {
317cdf0e10cSrcweir         return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
318cdf0e10cSrcweir     }
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 	//========================================================================
321cdf0e10cSrcweir 	//= OTimeDurationControl
322cdf0e10cSrcweir 	//========================================================================
323cdf0e10cSrcweir 	//------------------------------------------------------------------
OTimeDurationControl(::Window * pParent,WinBits nWinStyle)324cdf0e10cSrcweir     OTimeDurationControl::OTimeDurationControl( ::Window* pParent, WinBits nWinStyle )
325cdf0e10cSrcweir         :ONumericControl( pParent, nWinStyle )
326cdf0e10cSrcweir     {
327cdf0e10cSrcweir         getTypedControlWindow()->SetUnit( FUNIT_CUSTOM );
328cdf0e10cSrcweir         getTypedControlWindow()->SetCustomUnitText( String::CreateFromAscii( " ms" ) );
329cdf0e10cSrcweir         getTypedControlWindow()->SetCustomConvertHdl( LINK( this, OTimeDurationControl, OnCustomConvert ) );
330cdf0e10cSrcweir     }
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 	//------------------------------------------------------------------
~OTimeDurationControl()333cdf0e10cSrcweir     OTimeDurationControl::~OTimeDurationControl()
334cdf0e10cSrcweir     {
335cdf0e10cSrcweir     }
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 	//------------------------------------------------------------------
getControlType()338cdf0e10cSrcweir     ::sal_Int16 SAL_CALL OTimeDurationControl::getControlType() throw (::com::sun::star::uno::RuntimeException)
339cdf0e10cSrcweir     {
340cdf0e10cSrcweir         // don't use the base class'es method, it would claim we're a standard control, which
341cdf0e10cSrcweir         // we in fact aren't
342cdf0e10cSrcweir         return PropertyControlType::Unknown;
343cdf0e10cSrcweir     }
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 	//------------------------------------------------------------------
346cdf0e10cSrcweir     IMPL_LINK( OTimeDurationControl, OnCustomConvert, MetricField*, /*pField*/ )
347cdf0e10cSrcweir     {
348cdf0e10cSrcweir         long nMultiplier = 1;
349cdf0e10cSrcweir         if ( getTypedControlWindow()->GetCurUnitText().EqualsIgnoreCaseAscii( "ms" ) )
350cdf0e10cSrcweir             nMultiplier = 1;
351cdf0e10cSrcweir         if ( getTypedControlWindow()->GetCurUnitText().EqualsIgnoreCaseAscii( "s" ) )
352cdf0e10cSrcweir             nMultiplier = 1000;
353cdf0e10cSrcweir         else if ( getTypedControlWindow()->GetCurUnitText().EqualsIgnoreCaseAscii( "m" ) )
354cdf0e10cSrcweir             nMultiplier = 1000 * 60;
355cdf0e10cSrcweir         else if ( getTypedControlWindow()->GetCurUnitText().EqualsIgnoreCaseAscii( "h" ) )
356cdf0e10cSrcweir             nMultiplier = 1000 * 60 * 60;
357cdf0e10cSrcweir 
358cdf0e10cSrcweir         getTypedControlWindow()->SetValue( getTypedControlWindow()->GetLastValue() * nMultiplier );
359cdf0e10cSrcweir 
360cdf0e10cSrcweir         return 0L;
361cdf0e10cSrcweir     }
362cdf0e10cSrcweir 
363cdf0e10cSrcweir //............................................................................
364cdf0e10cSrcweir } // namespace pcr
365cdf0e10cSrcweir //............................................................................
366cdf0e10cSrcweir 
367