1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_
25 #define _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_
26 
27 #include "commoncontrol.hxx"
28 #define _ZFORLIST_DECLARE_TABLE
29 #include <svtools/fmtfield.hxx>
30 #include <svtools/fileurlbox.hxx>
31 #include "standardcontrol.hxx"
32 
33 class SvNumberFormatsSupplierObj;
34 
35 //............................................................................
36 namespace pcr
37 {
38 //............................................................................
39 
40     //========================================================================
41     //= NumberFormatSampleField
42     //========================================================================
43     class NumberFormatSampleField : public ControlWindow< FormattedField >
44     {
45     private:
46         typedef ControlWindow< FormattedField > BaseClass;
47 
48     public:
NumberFormatSampleField(Window * _pParent,WinBits _nStyle)49         NumberFormatSampleField( Window* _pParent, WinBits _nStyle )
50             :BaseClass( _pParent, _nStyle )
51         {
52         }
53 
54         void SetFormatSupplier( const SvNumberFormatsSupplierObj* pSupplier );
55 
56     protected:
57         virtual long PreNotify( NotifyEvent& rNEvt );
58     };
59 
60     //========================================================================
61     //= OFormatSampleControl
62     //========================================================================
63     typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, NumberFormatSampleField > OFormatSampleControl_Base;
64     class OFormatSampleControl : public OFormatSampleControl_Base
65     {
66     public:
67         OFormatSampleControl( Window* pParent, WinBits nWinStyle );
68 
69         // XPropertyControl
70         virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
71         virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
72         virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
73 
SetFormatSupplier(const SvNumberFormatsSupplierObj * _pSupplier)74         inline void SetFormatSupplier( const SvNumberFormatsSupplierObj* _pSupplier )
75         {
76             getTypedControlWindow()->SetFormatSupplier( _pSupplier );
77         }
78 
79         /** returns the default preview value for the given format key
80         *
81         * \param _pNF the number formatter
82         * \param _nFormatKey the format key
83         * \return current date or time or the value 1234.56789
84         */
85         static double getPreviewValue(SvNumberFormatter* _pNF,sal_Int32 _nFormatKey);
86 
87     private:
88         static double getPreviewValue( const SvNumberformat& i_rEntry );
89     };
90 
91     //========================================================================
92     //= FormatDescription
93     //========================================================================
94     struct FormatDescription
95     {
96         SvNumberFormatsSupplierObj*     pSupplier;
97         sal_Int32                       nKey;
98     };
99 
100     //========================================================================
101     //= OFormattedNumericControl
102     //========================================================================
103     typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< FormattedField > > OFormattedNumericControl_Base;
104     class OFormattedNumericControl : public OFormattedNumericControl_Base
105     {
106     private:
107         sal_Int32   m_nLastDecimalDigits;
108 
109     public:
110         OFormattedNumericControl( Window* pParent, WinBits nWinStyle = WB_TABSTOP);
111 
112         // XPropertyControl
113         virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
114         virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
115         virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
116 
117         void SetFormatDescription( const FormatDescription& rDesc );
118 
119         // make some FormattedField methods available
SetDecimalDigits(sal_uInt16 nPrecision)120         void SetDecimalDigits(sal_uInt16 nPrecision) { getTypedControlWindow()->SetDecimalDigits(nPrecision); m_nLastDecimalDigits = nPrecision; }
SetDefaultValue(double dDef)121         void SetDefaultValue(double dDef) { getTypedControlWindow()->SetDefaultValue(dDef); }
EnableEmptyField(sal_Bool bEnable)122         void EnableEmptyField(sal_Bool bEnable) { getTypedControlWindow()->EnableEmptyField(bEnable); }
SetThousandsSep(sal_Bool bEnable)123         void SetThousandsSep(sal_Bool bEnable) { getTypedControlWindow()->SetThousandsSep(bEnable); }
124 
125     protected:
126         ~OFormattedNumericControl();
127     };
128 
129     //========================================================================
130     //= OFileUrlControl
131     //========================================================================
132     typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< ::svt::FileURLBox > > OFileUrlControl_Base;
133     class OFileUrlControl : public OFileUrlControl_Base
134     {
135     public:
136         OFileUrlControl( Window* pParent, WinBits nWinStyle );
137 
138         // XPropertyControl
139         virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
140         virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
141         virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
142 
143     protected:
144         ~OFileUrlControl();
145     };
146 
147     //========================================================================
148     //= OTimeDurationControl
149     //========================================================================
150     class OTimeDurationControl : public ONumericControl
151     {
152     public:
153         OTimeDurationControl( ::Window* pParent, WinBits nWinStyle );
154         ~OTimeDurationControl();
155 
156         // XPropertyControl
157         ::sal_Int16 SAL_CALL getControlType() throw (::com::sun::star::uno::RuntimeException);
158 
159     private:
160         DECL_LINK( OnCustomConvert, MetricField* );
161     };
162 
163 //............................................................................
164 } // namespace pcr
165 //............................................................................
166 
167 #endif // _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_
168 
169