LibreOffice Module sc (master) 1
calcoptionsdlg.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
10#include <sal/config.h>
11
12#include <officecfg/Office/Calc.hxx>
13
14#include <calcconfig.hxx>
15#include "calcoptionsdlg.hxx"
16
17namespace {
18
19formula::FormulaGrammar::AddressConvention toAddressConvention(sal_Int32 nPos)
20{
21 switch (nPos)
22 {
23 case 1:
25 case 2:
27 case 3:
29 case 4:
31 case 0:
32 default:
33 ;
34 }
35
37}
38
39sal_Int32 toSelectedItem( formula::FormulaGrammar::AddressConvention eConv )
40{
41 switch (eConv)
42 {
44 return 1;
46 return 2;
48 return 3;
50 return 4;
51 default:
52 ;
53 }
54 return 0;
55}
56
57}
58
59ScCalcOptionsDialog::ScCalcOptionsDialog(weld::Window* pParent, const ScCalcConfig& rConfig, bool bWriteConfig)
60 : GenericDialogController(pParent, "modules/scalc/ui/formulacalculationoptions.ui", "FormulaCalculationOptions")
61 , maConfig(rConfig)
62 , mbSelectedEmptyStringAsZero(rConfig.mbEmptyStringAsZero)
63 , mbWriteConfig(bWriteConfig)
64 , mxEmptyAsZero(m_xBuilder->weld_check_button("checkEmptyAsZero"))
65 , mxConversion(m_xBuilder->weld_combo_box("comboConversion"))
66 , mxCurrentDocOnly(m_xBuilder->weld_check_button("current_doc"))
67 , mxSyntax(m_xBuilder->weld_combo_box("comboSyntaxRef"))
68{
69 mxConversion->set_active(static_cast<int>(rConfig.meStringConversion));
70 mxConversion->connect_changed(LINK(this, ScCalcOptionsDialog, ConversionModifiedHdl));
71 mxConversion->set_sensitive( !officecfg::Office::Calc::Formula::Syntax::StringConversion::isReadOnly() );
72
73 mxEmptyAsZero->set_active(rConfig.mbEmptyStringAsZero);
74 mxEmptyAsZero->connect_toggled(LINK(this, ScCalcOptionsDialog, AsZeroModifiedHdl));
76 mxEmptyAsZero->set_sensitive ( !officecfg::Office::Calc::Formula::Syntax::EmptyStringAsZero::isReadOnly() );
77
78 mxSyntax->set_active(toSelectedItem(rConfig.meStringRefAddressSyntax));
79 mxSyntax->connect_changed(LINK(this, ScCalcOptionsDialog, SyntaxModifiedHdl));
80 mxSyntax->set_sensitive ( !officecfg::Office::Calc::Formula::Syntax::StringRefAddressSyntax::isReadOnly() );
81
82 mxCurrentDocOnly->set_active(!mbWriteConfig);
83 mxCurrentDocOnly->connect_toggled(LINK(this, ScCalcOptionsDialog, CurrentDocOnlyHdl));
84}
85
87{
88}
89
91{
93 {
96 mxEmptyAsZero->set_active(false);
97 mxEmptyAsZero->set_sensitive(false);
98 break;
101 mxEmptyAsZero->set_active(true);
102 mxEmptyAsZero->set_sensitive(false);
103 break;
106 // Reset to the value the user selected before.
108 mxEmptyAsZero->set_sensitive(true);
110 break;
111 }
112}
113
114IMPL_LINK(ScCalcOptionsDialog, AsZeroModifiedHdl, weld::Toggleable&, rCheckBox, void )
115{
116 maConfig.mbEmptyStringAsZero = mbSelectedEmptyStringAsZero = rCheckBox.get_active();
117}
118
119IMPL_LINK(ScCalcOptionsDialog, ConversionModifiedHdl, weld::ComboBox&, rConv, void)
120{
121 maConfig.meStringConversion = static_cast<ScCalcConfig::StringConversion>(rConv.get_active());
122 CoupleEmptyAsZeroToStringConversion();
123}
124
125IMPL_LINK(ScCalcOptionsDialog, SyntaxModifiedHdl, weld::ComboBox&, rSyntax, void)
126{
127 maConfig.SetStringRefSyntax(toAddressConvention(rSyntax.get_active()));
128}
129
130IMPL_LINK(ScCalcOptionsDialog, CurrentDocOnlyHdl, weld::Toggleable&, rCheckBox, void)
131{
132 mbWriteConfig = !rCheckBox.get_active();
133}
134
135/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPL_LINK(ScCalcOptionsDialog, AsZeroModifiedHdl, weld::Toggleable &, rCheckBox, void)
std::unique_ptr< weld::ComboBox > mxSyntax
std::unique_ptr< weld::CheckButton > mxEmptyAsZero
void CoupleEmptyAsZeroToStringConversion()
ScCalcOptionsDialog(weld::Window *pParent, const ScCalcConfig &rConfig, bool bWriteConfig)
std::unique_ptr< weld::ComboBox > mxConversion
virtual ~ScCalcOptionsDialog() override
std::unique_ptr< weld::CheckButton > mxCurrentDocOnly
Configuration options for formula interpreter.
Definition: calcconfig.hxx:44
StringConversion meStringConversion
Definition: calcconfig.hxx:54
@ UNAMBIGUOUS
=1+"1" gives 2, but =1+"1.000" or =1+"x" give VALUE!
@ LOCALE
=1+"1.000" may be 2 or 1001 ... =1+"x" gives VALUE!
@ ILLEGAL
=1+"1" or =1+"x" give VALUE!
@ ZERO
=1+"1" or =1+"x" give 1
formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax
Definition: calcconfig.hxx:53
bool mbEmptyStringAsZero
Definition: calcconfig.hxx:55