summaryrefslogtreecommitdiff
path: root/extensions/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-07-14 16:45:39 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-07-15 15:00:56 +0200
commit299e128b5175f4c3d794848ab51e81d14385a547 (patch)
treeb2af5ebbd9c2692e121f0b6ba064d34bfef60a1a /extensions/source
parent0abbf64dc1ebe9f12523a69ce1cfd25fe189d869 (diff)
replace TimeSpinButton with FormattedSpinButton
with a TimeFormatter rather than have duplicate functionality Change-Id: I99f1f2aabee5f81485f97755ba3675870317cfb9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98791 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'extensions/source')
-rw-r--r--extensions/source/propctrlr/commoncontrol.cxx2
-rw-r--r--extensions/source/propctrlr/commoncontrol.hxx2
-rw-r--r--extensions/source/propctrlr/propcontroller.cxx2
-rw-r--r--extensions/source/propctrlr/standardcontrol.cxx20
-rw-r--r--extensions/source/propctrlr/standardcontrol.hxx11
5 files changed, 22 insertions, 15 deletions
diff --git a/extensions/source/propctrlr/commoncontrol.cxx b/extensions/source/propctrlr/commoncontrol.cxx
index 02f52a6ecd80..243bbd813b57 100644
--- a/extensions/source/propctrlr/commoncontrol.cxx
+++ b/extensions/source/propctrlr/commoncontrol.cxx
@@ -93,7 +93,7 @@ namespace pcr
setModified();
}
- IMPL_LINK_NOARG( CommonBehaviourControlHelper, TimeModifiedHdl, weld::TimeSpinButton&, void )
+ IMPL_LINK_NOARG( CommonBehaviourControlHelper, TimeModifiedHdl, weld::FormattedSpinButton&, void )
{
setModified();
}
diff --git a/extensions/source/propctrlr/commoncontrol.hxx b/extensions/source/propctrlr/commoncontrol.hxx
index 2097a88df3ff..919a7747c48c 100644
--- a/extensions/source/propctrlr/commoncontrol.hxx
+++ b/extensions/source/propctrlr/commoncontrol.hxx
@@ -91,7 +91,7 @@ namespace pcr
DECL_LINK( EditModifiedHdl, weld::Entry&, void );
DECL_LINK( MetricModifiedHdl, weld::MetricSpinButton&, void );
DECL_LINK( FormattedModifiedHdl, weld::FormattedSpinButton&, void );
- DECL_LINK( TimeModifiedHdl, weld::TimeSpinButton&, void );
+ DECL_LINK( TimeModifiedHdl, weld::FormattedSpinButton&, void );
DECL_LINK( DateModifiedHdl, SvtCalendarBox&, void );
DECL_LINK( GetFocusHdl, weld::Widget&, void );
DECL_LINK( LoseFocusHdl, weld::Widget&, void );
diff --git a/extensions/source/propctrlr/propcontroller.cxx b/extensions/source/propctrlr/propcontroller.cxx
index d75c117a3e20..76e92f064638 100644
--- a/extensions/source/propctrlr/propcontroller.cxx
+++ b/extensions/source/propctrlr/propcontroller.cxx
@@ -790,7 +790,7 @@ namespace pcr
case PropertyControlType::TimeField:
{
std::unique_ptr<weld::Builder> xBuilder(PropertyHandlerHelper::makeBuilder("modules/spropctrlr/ui/timefield.ui", m_xContext));
- auto pTimeSpinButton = xBuilder->weld_time_spin_button("timefield", TimeFieldFormat::F_SEC);
+ auto pTimeSpinButton = xBuilder->weld_formatted_spin_button("timefield");
auto pControl = new OTimeControl(std::move(pTimeSpinButton), std::move(xBuilder), bCreateReadOnly);
pControl->SetModifyHandler();
xControl = pControl;
diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx
index dc1891eab122..2084a9dae6bf 100644
--- a/extensions/source/propctrlr/standardcontrol.cxx
+++ b/extensions/source/propctrlr/standardcontrol.cxx
@@ -53,9 +53,11 @@ namespace pcr
using namespace ::com::sun::star::inspection;
//= OTimeControl
- OTimeControl::OTimeControl(std::unique_ptr<weld::TimeSpinButton> xWidget, std::unique_ptr<weld::Builder> xBuilder, bool bReadOnly)
+ OTimeControl::OTimeControl(std::unique_ptr<weld::FormattedSpinButton> xWidget, std::unique_ptr<weld::Builder> xBuilder, bool bReadOnly)
: OTimeControl_Base(PropertyControlType::TimeField, std::move(xBuilder), std::move(xWidget), bReadOnly)
+ , m_xFormatter(new weld::TimeFormatter(*getTypedControlWindow()))
{
+ m_xFormatter->SetExtFormat(ExtTimeFieldFormat::LongDuration);
}
void SAL_CALL OTimeControl::setValue( const Any& _rValue )
@@ -64,11 +66,11 @@ namespace pcr
if ( !( _rValue >>= aUNOTime ) )
{
getTypedControlWindow()->set_text("");
- getTypedControlWindow()->set_value(tools::Time(tools::Time::EMPTY));
+ m_xFormatter->SetTime(tools::Time(tools::Time::EMPTY));
}
else
{
- getTypedControlWindow()->set_value(::tools::Time(aUNOTime));
+ m_xFormatter->SetTime(::tools::Time(aUNOTime));
}
}
@@ -77,7 +79,7 @@ namespace pcr
Any aPropValue;
if ( !getTypedControlWindow()->get_text().isEmpty() )
{
- aPropValue <<= getTypedControlWindow()->get_value().GetUNOTime();
+ aPropValue <<= m_xFormatter->GetTime().GetUNOTime();
}
return aPropValue;
}
@@ -205,8 +207,10 @@ namespace pcr
ODateTimeControl::ODateTimeControl(std::unique_ptr<weld::Container> xWidget, std::unique_ptr<weld::Builder> xBuilder, bool bReadOnly)
: ODateTimeControl_Base(PropertyControlType::DateTimeField, std::move(xBuilder), std::move(xWidget), bReadOnly)
, m_xDate(std::make_unique<SvtCalendarBox>(m_xBuilder->weld_menu_button("datefield")))
- , m_xTime(m_xBuilder->weld_time_spin_button("timefield", TimeFieldFormat::F_SEC))
+ , m_xTime(m_xBuilder->weld_formatted_spin_button("timefield"))
+ , m_xFormatter(new weld::TimeFormatter(*m_xTime))
{
+ m_xFormatter->SetExtFormat(ExtTimeFieldFormat::LongDuration);
}
void SAL_CALL ODateTimeControl::setValue( const Any& _rValue )
@@ -215,7 +219,7 @@ namespace pcr
{
m_xDate->set_date(::Date(::Date::SYSTEM));
m_xTime->set_text("");
- m_xTime->set_value(tools::Time(tools::Time::EMPTY));
+ m_xFormatter->SetTime(tools::Time(tools::Time::EMPTY));
}
else
{
@@ -226,7 +230,7 @@ namespace pcr
::utl::typeConvert( aUNODateTime, aDateTime );
m_xDate->set_date(aDateTime);
- m_xTime->set_value(aDateTime);
+ m_xFormatter->SetTime(aDateTime);
}
}
@@ -235,7 +239,7 @@ namespace pcr
Any aPropValue;
if (!m_xTime->get_text().isEmpty())
{
- ::DateTime aDateTime(m_xDate->get_date(), m_xTime->get_value());
+ ::DateTime aDateTime(m_xDate->get_date(), m_xFormatter->GetTime());
util::DateTime aUNODateTime;
::utl::typeConvert( aDateTime, aUNODateTime );
diff --git a/extensions/source/propctrlr/standardcontrol.hxx b/extensions/source/propctrlr/standardcontrol.hxx
index 1b4fd2fd08dc..1eccceb9451e 100644
--- a/extensions/source/propctrlr/standardcontrol.hxx
+++ b/extensions/source/propctrlr/standardcontrol.hxx
@@ -35,11 +35,12 @@ namespace pcr
//= OTimeControl
- typedef CommonBehaviourControl<css::inspection::XPropertyControl, weld::TimeSpinButton> OTimeControl_Base;
+ typedef CommonBehaviourControl<css::inspection::XPropertyControl, weld::FormattedSpinButton> OTimeControl_Base;
class OTimeControl : public OTimeControl_Base
{
+ std::unique_ptr<weld::TimeFormatter> m_xFormatter;
public:
- OTimeControl(std::unique_ptr<weld::TimeSpinButton> xWidget, std::unique_ptr<weld::Builder> xBuilder, bool bReadOnly);
+ OTimeControl(std::unique_ptr<weld::FormattedSpinButton> xWidget, std::unique_ptr<weld::Builder> xBuilder, bool bReadOnly);
// XPropertyControl
virtual css::uno::Any SAL_CALL getValue() override;
@@ -52,7 +53,7 @@ namespace pcr
getTypedControlWindow()->connect_value_changed( LINK( this, CommonBehaviourControlHelper, TimeModifiedHdl ) );
}
- virtual weld::Widget* getWidget() override { return &getTypedControlWindow()->get_widget(); }
+ virtual weld::Widget* getWidget() override { return getTypedControlWindow(); }
};
//= ODateControl
@@ -108,7 +109,8 @@ namespace pcr
{
private:
std::unique_ptr<SvtCalendarBox> m_xDate;
- std::unique_ptr<weld::TimeSpinButton> m_xTime;
+ std::unique_ptr<weld::FormattedSpinButton> m_xTime;
+ std::unique_ptr<weld::TimeFormatter> m_xFormatter;
public:
ODateTimeControl(std::unique_ptr<weld::Container> xWidget, std::unique_ptr<weld::Builder> xBuilder, bool bReadOnly);
@@ -126,6 +128,7 @@ namespace pcr
virtual void SAL_CALL disposing() override
{
+ m_xFormatter.reset();
m_xTime.reset();
m_xDate.reset();
ODateTimeControl_Base::disposing();