Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / extensions / source / propctrlr / usercontrol.hxx
blob2dde63d403efcff133d627d21d4767a93053b5d1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_USERCONTROL_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_USERCONTROL_HXX
23 #include "commoncontrol.hxx"
24 #include <svtools/fmtfield.hxx>
25 #include <svtools/fileurlbox.hxx>
26 #include "standardcontrol.hxx"
28 class SvNumberFormatsSupplierObj;
31 namespace pcr
35 //= NumberFormatSampleField
37 class NumberFormatSampleField : public FormattedField
39 public:
40 NumberFormatSampleField( vcl::Window* _pParent, WinBits _nStyle )
41 : FormattedField(_pParent, _nStyle)
42 , m_pHelper(nullptr)
46 void SetFormatSupplier( const SvNumberFormatsSupplierObj* pSupplier );
47 void setControlHelper( CommonBehaviourControlHelper& _rControlHelper ) { m_pHelper = &_rControlHelper; }
49 protected:
50 virtual bool PreNotify( NotifyEvent& rNEvt ) override;
51 private:
52 CommonBehaviourControlHelper* m_pHelper;
56 //= OFormatSampleControl
58 typedef CommonBehaviourControl< css::inspection::XPropertyControl, NumberFormatSampleField > OFormatSampleControl_Base;
59 class OFormatSampleControl : public OFormatSampleControl_Base
61 public:
62 explicit OFormatSampleControl( vcl::Window* pParent );
64 // XPropertyControl
65 virtual css::uno::Any SAL_CALL getValue() override;
66 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
67 virtual css::uno::Type SAL_CALL getValueType() override;
69 void SetFormatSupplier( const SvNumberFormatsSupplierObj* _pSupplier )
71 getTypedControlWindow()->SetFormatSupplier( _pSupplier );
74 /** returns the default preview value for the given format key
76 * \param _pNF the number formatter
77 * \param _nFormatKey the format key
78 * \return current date or time or the value 1234.56789
80 static double getPreviewValue(SvNumberFormatter* _pNF,sal_Int32 _nFormatKey);
82 private:
83 static double getPreviewValue( const SvNumberformat& i_rEntry );
87 //= FormatDescription
89 struct FormatDescription
91 SvNumberFormatsSupplierObj* pSupplier;
92 sal_Int32 nKey;
96 //= OFormattedNumericControl
98 typedef CommonBehaviourControl< css::inspection::XPropertyControl, FormattedField > OFormattedNumericControl_Base;
99 class OFormattedNumericControl : public OFormattedNumericControl_Base
101 private:
102 sal_Int32 m_nLastDecimalDigits;
104 public:
105 OFormattedNumericControl( vcl::Window* pParent, WinBits nWinStyle);
107 // XPropertyControl
108 virtual css::uno::Any SAL_CALL getValue() override;
109 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
110 virtual css::uno::Type SAL_CALL getValueType() override;
112 void SetFormatDescription( const FormatDescription& rDesc );
114 // make some FormattedField methods available
115 void SetDecimalDigits(sal_uInt16 nPrecision) { getTypedControlWindow()->SetDecimalDigits(nPrecision); m_nLastDecimalDigits = nPrecision; }
116 void SetDefaultValue(double dDef) { getTypedControlWindow()->SetDefaultValue(dDef); }
117 void EnableEmptyField(bool bEnable) { getTypedControlWindow()->EnableEmptyField(bEnable); }
118 void SetThousandsSep(bool bEnable) { getTypedControlWindow()->SetThousandsSep(bEnable); }
120 protected:
121 virtual ~OFormattedNumericControl() override;
125 //= OFileUrlControl
127 typedef CommonBehaviourControl< css::inspection::XPropertyControl, ::svt::FileURLBox > OFileUrlControl_Base;
128 class OFileUrlControl : public OFileUrlControl_Base
130 public:
131 explicit OFileUrlControl( vcl::Window* pParent );
133 // XPropertyControl
134 virtual css::uno::Any SAL_CALL getValue() override;
135 virtual void SAL_CALL setValue( const css::uno::Any& _value ) override;
136 virtual css::uno::Type SAL_CALL getValueType() override;
138 protected:
139 virtual ~OFileUrlControl() override;
143 //= OTimeDurationControl
145 class OTimeDurationControl : public ONumericControl
147 public:
148 explicit OTimeDurationControl( vcl::Window* pParent );
149 virtual ~OTimeDurationControl() override;
151 // XPropertyControl
152 ::sal_Int16 SAL_CALL getControlType() override;
154 private:
155 DECL_LINK( OnCustomConvert, MetricFormatter&, void );
159 } // namespace pcr
162 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_USERCONTROL_HXX
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */