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