1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include "commoncontrol.hxx"
23 #include <svtools/inettbc.hxx>
24 #include <svl/zforlist.hxx>
26 class SvNumberFormatsSupplierObj
;
30 //= OFormatSampleControl
31 typedef CommonBehaviourControl
<css::inspection::XPropertyControl
, weld::Container
> OFormatSampleControl_Base
;
32 class OFormatSampleControl
: public OFormatSampleControl_Base
35 std::unique_ptr
<weld::FormattedSpinButton
> m_xSpinButton
;
36 std::unique_ptr
<weld::Entry
> m_xEntry
;
38 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
41 OFormatSampleControl(std::unique_ptr
<weld::Container
> xWidget
, std::unique_ptr
<weld::Builder
> xBuilder
, bool bReadOnly
);
44 virtual css::uno::Any SAL_CALL
getValue() override
;
45 virtual void SAL_CALL
setValue( const css::uno::Any
& _value
) override
;
46 virtual css::uno::Type SAL_CALL
getValueType() override
;
48 virtual void SAL_CALL
disposing() override
51 m_xSpinButton
.reset();
52 OFormatSampleControl_Base::disposing();
55 virtual void SetModifyHandler() override
57 m_xEntry
->connect_focus_in( LINK( this, CommonBehaviourControlHelper
, GetFocusHdl
) );
58 m_xEntry
->connect_focus_out( LINK( this, CommonBehaviourControlHelper
, LoseFocusHdl
) );
59 m_xSpinButton
->connect_value_changed(LINK(this, CommonBehaviourControlHelper
, FormattedModifiedHdl
));
60 m_xSpinButton
->connect_changed(LINK(this, CommonBehaviourControlHelper
, EditModifiedHdl
));
63 void SetFormatSupplier(const SvNumberFormatsSupplierObj
* pSupplier
);
65 virtual weld::Widget
* getWidget() override
{ return getTypedControlWindow(); }
67 /** returns the default preview value for the given format key
69 * \param _pNF the number formatter
70 * \param _nFormatKey the format key
71 * \return current date or time or the value 1234.56789
73 static double getPreviewValue(SvNumberFormatter
const * pNF
, sal_Int32 nFormatKey
);
76 static double getPreviewValue( const SvNumberformat
& i_rEntry
);
80 struct FormatDescription
82 SvNumberFormatsSupplierObj
* pSupplier
;
86 //= OFormattedNumericControl
87 typedef CommonBehaviourControl
<css::inspection::XPropertyControl
, weld::FormattedSpinButton
> OFormattedNumericControl_Base
;
88 class OFormattedNumericControl
: public OFormattedNumericControl_Base
91 OFormattedNumericControl(std::unique_ptr
<weld::FormattedSpinButton
> xWidget
, std::unique_ptr
<weld::Builder
> xBuilder
, bool bReadOnly
);
94 virtual css::uno::Any SAL_CALL
getValue() override
;
95 virtual void SAL_CALL
setValue( const css::uno::Any
& _value
) override
;
96 virtual css::uno::Type SAL_CALL
getValueType() override
;
98 void SetFormatDescription( const FormatDescription
& rDesc
);
100 // make some FormattedField methods available
101 void SetDecimalDigits(sal_uInt16 nPrecision
) { getTypedControlWindow()->GetFormatter().SetDecimalDigits(nPrecision
); }
102 void SetDefaultValue(double dDef
) { getTypedControlWindow()->GetFormatter().SetDefaultValue(dDef
); }
104 virtual void SetModifyHandler() override
106 OFormattedNumericControl_Base::SetModifyHandler();
107 getTypedControlWindow()->connect_value_changed(LINK(this, CommonBehaviourControlHelper
, FormattedModifiedHdl
));
108 getTypedControlWindow()->connect_changed(LINK(this, CommonBehaviourControlHelper
, EditModifiedHdl
));
111 virtual weld::Widget
* getWidget() override
{ return getTypedControlWindow(); }
114 virtual ~OFormattedNumericControl() override
;
118 typedef CommonBehaviourControl
<css::inspection::XPropertyControl
, SvtURLBox
> OFileUrlControl_Base
;
119 class OFileUrlControl
: public OFileUrlControl_Base
122 DECL_LINK(URLModifiedHdl
, weld::ComboBox
&, void);
124 OFileUrlControl(std::unique_ptr
<SvtURLBox
> xWidget
, std::unique_ptr
<weld::Builder
> xBuilder
, bool bReadOnly
);
127 virtual css::uno::Any SAL_CALL
getValue() override
;
128 virtual void SAL_CALL
setValue( const css::uno::Any
& _value
) override
;
129 virtual css::uno::Type SAL_CALL
getValueType() override
;
131 virtual void SetModifyHandler() override
133 OFileUrlControl_Base::SetModifyHandler();
134 SvtURLBox
* pControlWindow
= getTypedControlWindow();
135 // tdf#140239 and tdf#141084 don't notify that the control has changed content until focus-out
136 pControlWindow
->connect_focus_out(LINK(this, CommonBehaviourControlHelper
, LoseFocusHdl
));
137 pControlWindow
->connect_changed(LINK(this, OFileUrlControl
, URLModifiedHdl
));
140 virtual weld::Widget
* getWidget() override
{ return getTypedControlWindow()->getWidget(); }
143 virtual ~OFileUrlControl() override
;
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */