LibreOffice Module sc (master) 1
mtrindlg.cxx
Go to the documentation of this file.
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#undef SC_DLLIMPLEMENTATION
21
22#include <mtrindlg.hxx>
23
25 const OUString& sDialogName,
26 tools::Long nCurrent,
27 tools::Long nDefault,
28 FieldUnit eFUnit,
29 sal_uInt16 nDecimals,
30 tools::Long nMaximum,
31 tools::Long nMinimum)
32
33 : GenericDialogController(pParent, "modules/scalc/ui/" + sDialogName.toAsciiLowerCase() + ".ui", sDialogName)
34 , m_xEdValue(m_xBuilder->weld_metric_spin_button("value", FieldUnit::CM))
35 , m_xBtnDefVal(m_xBuilder->weld_check_button("default"))
36{
37 m_xBtnDefVal->connect_toggled(LINK(this, ScMetricInputDlg, SetDefValHdl));
38 m_xEdValue->connect_value_changed(LINK( this, ScMetricInputDlg, ModifyHdl));
39
40 m_xEdValue->set_unit(eFUnit);
41 m_xEdValue->set_digits(nDecimals);
42 m_xEdValue->set_range(m_xEdValue->normalize(nMinimum),
43 m_xEdValue->normalize(nMaximum), FieldUnit::TWIP);
44
45 sal_Int64 nMin(0), nMax(0);
46 m_xEdValue->get_range(nMin, nMax, FieldUnit::TWIP);
47
48 auto nIncrement = m_xEdValue->normalize(1);
49 m_xEdValue->set_increments(nIncrement / 10, nIncrement, FieldUnit::NONE);
50 m_xEdValue->set_value(m_xEdValue->normalize(nDefault), FieldUnit::TWIP);
51 nDefaultValue = m_xEdValue->get_value(FieldUnit::NONE);
52 m_xEdValue->set_value(m_xEdValue->normalize(nCurrent), FieldUnit::TWIP);
53 nCurrentValue = m_xEdValue->get_value(FieldUnit::NONE);
55}
56
58{
59}
60
62{
63/*
64 with decimal digits
65
66 double nVal = m_xEdValue->GetValue( eUnit );
67 sal_uInt16 nDecs = m_xEdValue->GetDecimalDigits();
68 double nFactor = 0.0;
69
70 // static long ImpPower10( sal_uInt16 nDecs )
71 {
72 nFactor = 1.0;
73
74 for ( sal_uInt16 i=0; i < nDecs; i++ )
75 nFactor *= 10.0;
76 }
77
78 return nVal / nFactor;
79*/
80 // first cut off the decimal digits - not that great...
81
82 return m_xEdValue->denormalize(m_xEdValue->get_value(FieldUnit::TWIP));
83}
84
85// Handler:
86
88{
89 if (m_xBtnDefVal->get_active())
90 {
91 nCurrentValue = m_xEdValue->get_value(FieldUnit::NONE);
92 m_xEdValue->set_value(nDefaultValue, FieldUnit::NONE);
93 }
94 else
95 m_xEdValue->set_value(nCurrentValue, FieldUnit::NONE);
96}
97
99{
100 m_xBtnDefVal->set_active(nDefaultValue == m_xEdValue->get_value(FieldUnit::NONE));
101}
102
103/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~ScMetricInputDlg() override
Definition: mtrindlg.cxx:57
std::unique_ptr< weld::MetricSpinButton > m_xEdValue
Definition: mtrindlg.hxx:40
ScMetricInputDlg(weld::Window *pParent, const OUString &sDialogName, tools::Long nCurrent, tools::Long nDefault, FieldUnit eFUnit, sal_uInt16 nDecimals, tools::Long nMaximum, tools::Long nMinimum)
Definition: mtrindlg.cxx:24
std::unique_ptr< weld::CheckButton > m_xBtnDefVal
Definition: mtrindlg.hxx:41
int GetInputValue() const
Definition: mtrindlg.cxx:61
FieldUnit
IMPL_LINK_NOARG(ScMetricInputDlg, SetDefValHdl, weld::Toggleable &, void)
Definition: mtrindlg.cxx:87
long Long