1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: usercontrol.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_
32 #define _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_
34 #include "commoncontrol.hxx"
35 #define _ZFORLIST_DECLARE_TABLE
36 #include <svtools/fmtfield.hxx>
37 #include <svtools/fileurlbox.hxx>
38 #include "standardcontrol.hxx"
40 class SvNumberFormatsSupplierObj
;
42 //............................................................................
45 //............................................................................
47 //========================================================================
48 //= NumberFormatSampleField
49 //========================================================================
50 class NumberFormatSampleField
: public ControlWindow
< FormattedField
>
53 typedef ControlWindow
< FormattedField
> BaseClass
;
56 NumberFormatSampleField( Window
* _pParent
, WinBits _nStyle
)
57 :BaseClass( _pParent
, _nStyle
)
61 void SetFormatSupplier( const SvNumberFormatsSupplierObj
* pSupplier
);
64 virtual long PreNotify( NotifyEvent
& rNEvt
);
67 //========================================================================
68 //= OFormatSampleControl
69 //========================================================================
70 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, NumberFormatSampleField
> OFormatSampleControl_Base
;
71 class OFormatSampleControl
: public OFormatSampleControl_Base
74 OFormatSampleControl( Window
* pParent
, WinBits nWinStyle
);
77 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
78 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
79 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
81 inline void SetFormatSupplier( const SvNumberFormatsSupplierObj
* _pSupplier
)
83 getTypedControlWindow()->SetFormatSupplier( _pSupplier
);
86 /** returns the default preview value for the given format key
88 * \param _pNF the number formatter
89 * \param _nFormatKey the format key
90 * \return current date or time or the value 1234.56789
92 static double getPreviewValue(SvNumberFormatter
* _pNF
,sal_Int32 _nFormatKey
);
95 //========================================================================
97 //========================================================================
98 struct FormatDescription
100 SvNumberFormatsSupplierObj
* pSupplier
;
104 //========================================================================
105 //= OFormattedNumericControl
106 //========================================================================
107 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< FormattedField
> > OFormattedNumericControl_Base
;
108 class OFormattedNumericControl
: public OFormattedNumericControl_Base
111 sal_Int32 m_nLastDecimalDigits
;
114 OFormattedNumericControl( Window
* pParent
, WinBits nWinStyle
= WB_TABSTOP
);
117 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
118 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
119 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
121 void SetFormatDescription( const FormatDescription
& rDesc
);
123 // make some FormattedField methods available
124 void SetDecimalDigits(sal_uInt16 nPrecision
) { getTypedControlWindow()->SetDecimalDigits(nPrecision
); m_nLastDecimalDigits
= nPrecision
; }
125 void SetDefaultValue(double dDef
) { getTypedControlWindow()->SetDefaultValue(dDef
); }
126 void EnableEmptyField(sal_Bool bEnable
) { getTypedControlWindow()->EnableEmptyField(bEnable
); }
127 void SetThousandsSep(sal_Bool bEnable
) { getTypedControlWindow()->SetThousandsSep(bEnable
); }
130 ~OFormattedNumericControl();
133 //========================================================================
135 //========================================================================
136 typedef CommonBehaviourControl
< ::com::sun::star::inspection::XPropertyControl
, ControlWindow
< ::svt::FileURLBox
> > OFileUrlControl_Base
;
137 class OFileUrlControl
: public OFileUrlControl_Base
140 OFileUrlControl( Window
* pParent
, WinBits nWinStyle
);
143 virtual ::com::sun::star::uno::Any SAL_CALL
getValue() throw (::com::sun::star::uno::RuntimeException
);
144 virtual void SAL_CALL
setValue( const ::com::sun::star::uno::Any
& _value
) throw (::com::sun::star::beans::IllegalTypeException
, ::com::sun::star::uno::RuntimeException
);
145 virtual ::com::sun::star::uno::Type SAL_CALL
getValueType() throw (::com::sun::star::uno::RuntimeException
);
151 //========================================================================
152 //= OTimeDurationControl
153 //========================================================================
154 class OTimeDurationControl
: public ONumericControl
157 OTimeDurationControl( ::Window
* pParent
, WinBits nWinStyle
);
158 ~OTimeDurationControl();
161 ::sal_Int16 SAL_CALL
getControlType() throw (::com::sun::star::uno::RuntimeException
);
164 DECL_LINK( OnCustomConvert
, MetricField
* );
167 //............................................................................
169 //............................................................................
171 #endif // _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_