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